Skip to content

Instantly share code, notes, and snippets.

@diwakergupta
Created June 3, 2009 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diwakergupta/122709 to your computer and use it in GitHub Desktop.
Save diwakergupta/122709 to your computer and use it in GitHub Desktop.
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