wereldmuis
Waltham
A story about this — 1 year ago
Code Complete, on the subject of measuring performance, from Chapter 25, page 604:
Whether you use someone else’s tool or write your own code to make the measurements, make sure that you’re measuring only the execution time of the code you’re tuning. Use the number of CPU clock ticks allocated to your program rather than the time of day. Otherwise, when the system switches from your program to another program, one of your routines will be penalized for the time spent executing another program.Nice point, since in many Java examples I’ve seen System.currentTimeMillis() used to time sections of code, as is done in this article on micro-tuning. I’ve done it myself. It’s probably pretty safe for some uses, but something that you should think twice about in others.


















