• Post Reply Bookmark Topic Watch Topic
  • New Topic

Timing?  RSS feed

 
Joshua Rodrigues
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I time how long it takes to print out a simple Hello World statement, it takes 1ms. What factors into the 1ms timing of the Hello World statement? Hardware, anything within the JVM (if so, be specific, please), etc.? Thanks!
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you think would effect the time it takes and why?
Have you tried timing printing say 50 simple Hello World statements?
 
Joshua Rodrigues
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:What do you think would effect the time it takes and why?
Have you tried timing printing say 50 simple Hello World statements?

Last time I did a test for Hello World, it ran in 1ms, but that was so long ago. When redoing the test, it now runs at 0ms. Or rather 207 microseconds.
1 Statement = 0 milliseconds / 207 microseconds.
50 Statements = 7 milliseconds / 7,028 microseconds.
What do I think affects the time it takes? I would say the OS, though I could be wrong. Am I?
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So why do you think running 50 statements doesn't take 50 times as long?

Is the OS the only thing you think will effect the time?
 
Joshua Rodrigues
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:So why do you think running 50 statements doesn't take 50 times as long?

Is the OS the only thing you think will effect the time?

I honestly haven't a clue for either of those questions. Mind shedding some light?
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. If the time taken isn't linear then possibly:
The resolution of your timer isn't sufficient for you to be able to accurately measure a single print out
The act of measuring takes a certain amount of time (which will be a constant and will be more significant on shorter time events)
The compiler/runtime has performed some level of optimization etc

2. Think about all the things that can make any computer faster/slower such as processor, motherboard, caching, memory access speed, available memory, what else is currently running etc etc
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!