renamed all modules

This commit is contained in:
Andy Clement
2014-01-15 11:36:24 -08:00
parent 342420b2ed
commit ceef61cf98
1055 changed files with 301 additions and 259 deletions

View File

@@ -0,0 +1,42 @@
package perf.one;
public class Caller {
Target target = new Target();
public long run() {
long stime = System.nanoTime();
for (int i = 0; i < 1000000; i++) {
target.foo();
}
// int total = 0;
// for (int i = 0; i < 8000000; i++) {
// total += target.bar(123);
// }
// for (int i = 0; i < 8000000; i++) {
// target.goo("abc", 123);
// }
return (System.nanoTime() - stime);
}
public void warmup() {
for (int i = 0; i < 1000; i++) {
run();
}
}
public static void main(String[] argv) {
Caller c = new Caller();
c.warmup();
System.out.println("real run");
c.execute();
c.execute();
c.execute();
c.execute();
c.execute();
}
public void execute() {
System.out.println((run() / 1000000.0d) + "ms");
}
}

View File

@@ -0,0 +1,42 @@
package perf.one;
public class CallerB {
TargetB target = new TargetB();
public long run() {
long stime = System.nanoTime();
for (int i = 0; i < 100000; i++) {
target.foo();
}
// int total = 0;
// for (int i = 0; i < 8000000; i++) {
// total += target.bar(123);
// }
// for (int i = 0; i < 8000000; i++) {
// target.goo("abc", 123);
// }
return (System.nanoTime() - stime);
}
public void warmup() {
for (int i = 0; i < 1000; i++) {
run();
}
}
public static void main(String[] argv) {
CallerB c = new CallerB();
c.warmup();
System.out.println("real run");
c.execute();
c.execute();
c.execute();
c.execute();
c.execute();
}
public void execute() {
System.out.println((run() / 1000000.0d) + "ms");
}
}

View File

@@ -0,0 +1,22 @@
package perf.one;
public class Target {
int j;
public void foo() {
for (int i = 0; i < 100; i++) {
j = 5;
}
}
public int bar(int i) {
j = 5;
return i;
}
public void goo(String s, int i) {
j = 5;
}
}

View File

@@ -0,0 +1,22 @@
package perf.one;
public class TargetB {
int j;
public void foo() {
for (int i = 0; i < 20; i++) {
j = 5;
}
}
public int bar(int i) {
j = 5;
return i;
}
public void goo(String s, int i) {
j = 5;
}
}