Skip to content

Instantly share code, notes, and snippets.

@diwakergupta
Created June 1, 2009 20:53
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/121790 to your computer and use it in GitHub Desktop.
Save diwakergupta/121790 to your computer and use it in GitHub Desktop.
import std.stdio;
import std.string;
import std.conv;
class AllocationItem {
int value;
this(int v) {value = v;}
};
void RunAllocations(int iters) {
int sum = 0;
for (int i = 0; i < iters; ++i) {
AllocationItem item = new AllocationItem(i);
item.value = i;
sum += item.value;
}
printf("%d\n", sum);
}
int main(char[][] args) {
if (args.length < 3) {
writefln("Bad commandline");
return 1;
}
string benchmark = args[1];
int iters = toInt(args[2]);
if (benchmark == "allocations") {
RunAllocations(iters);
} else {
writefln("Invalid benchmark name ", benchmark);
return 2;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment