• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Strange results for time taken

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- inaccuracy of the clock?

- optimizations done by the hot spot engine?
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic