|
|
|
|
|
by gmokki
548 days ago
|
|
I usually do a var innerCount = 2000; // should run about 2 seconds
for (var i=0; i<1000; i++) {
var start = currentMillis();
for (var j=0; j<innerCount; j++) {
benchmark method();
}
best = min(best, (currentMillis() - start) / (double) innerCount);
} That way I can both get enough precision form the millisecond resolution and run the whole thing enough times to get the best result without JIT/GC pauses.
The result is usually very stable, even when benchmarking calls to database (running locally). |
|
My point was to minimize stuff that will get JITed—like console functions. People don’t realize how much code is in there that is not native.