aspose file tools*
The moose likes Performance and the fly likes Strange results for time taken Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Strange results for time taken " Watch "Strange results for time taken " New topic
Author

Strange results for time taken

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Hi, for my rubiks cube, I timed the average time to do a repaint for each 'animated frame' of a twist of the cube.

Strangely, this starts off at about 16ms, then after several twists goes down to 12ms.
I can't see why this happens, possibly an impossible question to solve without experimenting with code, but is there any obvious reason for this?

Thanks for any help.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
- inaccuracy of the clock?

- optimizations done by the hot spot engine?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39828
    
  28
I have had the same phenomonon with AffineTransforms, which run faster the second time they are executed. Probably JIT (="just in time") compilation; when the HotSpot machine recompiles the repeatedly-used code, it runs faster.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Also, the first time through it may still be loading some classes. This is pretty much normal behavior for Java programs - the Just in Time compiler makes things faster as they run more.


"I'm not back." - Bill Harding, Twister
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
I thought it still maybe doing some other work, but if I leave it for a minute after everything is loaded and ready to use, it still starts at 16ms, not a big deal.

I rather know that it isn't a fault with the code, and that its just one of those things.
 
wood burning stoves
 
subject: Strange results for time taken