Skip to content

Instantly share code, notes, and snippets.

@mastersobg
Created January 14, 2013 19:36
Show Gist options
  • Save mastersobg/4532676 to your computer and use it in GitHub Desktop.
Save mastersobg/4532676 to your computer and use it in GitHub Desktop.
public class Test {
static class Timer {
long time;
long current;
public void reset() {
time = 0;
}
public void start() {
current = System.currentTimeMillis();
}
public void end() {
time += System.currentTimeMillis() - current;
}
}
void test() {
Timer t = new Timer();
t.start();
byte a = 10;
byte b = 20;
byte c = 0;
for(long i = 0; i < 10000000000l; ++i) {
c += a + b;
}
t.end();
System.out.println("Total time = " + t.time + " value = " + c);
}
public void run() {
test();
test();
test();
test();
test();
test();
test();
test();
}
public static void main(String []args) {
new Test().run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment