Created
June 3, 2009 00:32
-
-
Save diwakergupta/122709 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
class AllocationItem { | |
int value; | |
public AllocationItem(int value) { | |
this.value = value; | |
} | |
} | |
public class Benchmark { | |
public static void main(String[] args) { | |
if (args.length < 2) { | |
System.err.println("Bad commandline"); | |
return; | |
} | |
String benchmark = args[0]; | |
int iters = Integer.parseInt(args[1]); | |
if (benchmark.equals("allocations")) { | |
RunAllocations(iters); | |
} else { | |
System.err.println("Invalid benchmark name"); | |
} | |
} | |
private static void RunAllocations(int iters) { | |
int sum = 0; | |
for (int i = 0; i < iters; ++i) { | |
AllocationItem item = new AllocationItem(i); | |
sum += item.value; | |
} | |
System.out.println("Ran " + iters + " allocations of RunAllocations. " + | |
"Final value: " + sum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment