Created
June 1, 2009 20:53
-
-
Save diwakergupta/121790 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
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