Cost of Java Casting

Hi Im trying to compare the cost of bitshifting to the cost of the casting of Java primitive types.How many atomic operations does casting require? Any comments?Jochem
[209 byte] By [jochem1] at [2007-9-26 8:56:14]
# 1

The cost of one operation compared to another will be different for every JVM. The best way to know the time it takes for a JVM to perform an operation is to time it.

However, such small optimizations rarely make any difference in the overall speed of your program. First, get your program to work, then determine if it runs too slowly. If it does, profile the code and focus your optimization efforts on the code that's taking the most time. It will almost never be low-level operations like casting or bit shifting, unless that's nearly all your program does.

schapel at 2007-7-1 19:55:19 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

...>cost of bitshifting to the cost of the casting of Java primitive types.

I give up... aren't those two different things that have nothing to do with each other? Comparisons are done so one can use the faster one, but I can't figure out a statement where those two operations are interchangable. So could someone provide an example?

jschell at 2007-7-1 19:55:19 > top of Java-index,Java HotSpot Virtual Machine,Specifications...