Last active
August 29, 2017 23:28
-
-
Save jordansissel/4a3c33985e7e1c9b9a564818f0df6c86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Foo { | |
private static final int ITERATIONS = 10000000; | |
public static void main(String[] args) { | |
Foo foo = new Foo(); | |
int i = Integer.parseInt(args[0]); | |
System.out.println(i); | |
if (args[1].equals("a")) { | |
System.out.println("a"); | |
for (int z = ITERATIONS; z > 0; z--) { | |
foo.a(i); | |
} | |
} else { | |
System.out.println("b"); | |
for (int z = ITERATIONS; z > 0; z--) { | |
foo.b(i); | |
} | |
} | |
} | |
public Foo() { } | |
public void a(int count) { | |
while (count > 0) { | |
count -= 1; | |
} | |
} | |
public void b(int count) { | |
do { | |
count -= 1; | |
} while (count > 0); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⓿ wopr(~) | |
% perf stat java Foo 1 a |& grep -v 'not supported' | |
1 | |
a | |
Performance counter stats for 'java Foo 1 a': | |
117.422078 task-clock (msec) # 1.183 CPUs utilized | |
201 context-switches # 0.002 M/sec | |
42 cpu-migrations # 0.358 K/sec | |
2,792 page-faults # 0.024 M/sec | |
191,820,684 cycles # 1.634 GHz | |
212,036,834 instructions # 1.11 insns per cycle | |
39,703,674 branches # 338.128 M/sec | |
1,367,419 branch-misses # 3.44% of all branches | |
0.099271927 seconds time elapsed | |
⓿ wopr(~) | |
% perf stat java Foo 1 b |& grep -v 'not supported' | |
1 | |
b | |
Performance counter stats for 'java Foo 1 b': | |
121.188996 task-clock (msec) # 1.159 CPUs utilized | |
198 context-switches # 0.002 M/sec | |
47 cpu-migrations # 0.388 K/sec | |
2,502 page-faults # 0.021 M/sec | |
189,602,621 cycles # 1.565 GHz | |
209,196,956 instructions # 1.10 insns per cycle | |
39,064,414 branches # 322.343 M/sec | |
1,352,431 branch-misses # 3.46% of all branches | |
0.104585771 seconds time elapsed | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment