micro-benchmark

How do I write a correct micro-benchmark in Java?

As the title says. How do you write (and run) a correct micro-benchmark in Java? I'm looking here for code samples and comments illustrating various things to think about. Example: Should the benchmark measure time/iteration or iterations/time, and why? Near Duplicate of: http://stackoverflow.com/questions/410437/is-stopwatch-benchmar...

Drain the instruction pipeline of Intel Core 2 Duo?

I'm writing some micro-benchmarking code for some very short operations in C. For example, one thing I'm measuring is how many cycles are needed to call an empty function depending on the number of arguments passed. Currently, I'm timing using an RDTSC instruction before and after each operation to get the CPU's cycle count. However, I...

Java: Why do two consecutive calls to the same method yield different times for execution ...

Here is a sample code: public class TestIO{ public static void main(String[] str){ TestIO t = new TestIO(); t.fOne(); t.fTwo(); t.fOne(); t.fTwo(); } public void fOne(){ long t1, t2; t1 = System.nanoTime(); int i = 10; int j = 10; int k = j*i; System.out.println(k); ...

Better way to do simple performance testing

When comparing the performance of operations this is how I would typicaly do the tests: <?php $w = 'world'; $start1 = microtime(true); for($i=0;$i<10000;$i++) echo 'Hello ' . $w . '!'; $end1 = microtime(true); $start2 = microtime(true); for($i=0;$i<10000;$i++) echo "Hello $w!"; $end2 = microtime(true); $start3 = microtime(true...

How to benchmark on multi-core processors

I am looking for ways to perform micro-benchmarks on multi-core processors. Context: At about the same time desktop processors introduced out-of-order execution that made performance hard to predict, they, perhaps not coincidentally, also introduced special instructions to get very precise timings. Example of these instructions are rdt...