Skip to content

Commit

Permalink
tests/bench: Accepts command-line arguments.
Browse files Browse the repository at this point in the history
"level: <n>" and "circumvent-boxing".
  • Loading branch information
stevefolta committed Jan 25, 2009
1 parent acad2ec commit c1b9f5f
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions tests/bench/main
@@ -1,12 +1,35 @@
trylon Bench

main: args
# Parse arguments.
circumvent-boxing = false
level = 33
args pop-front
while args num-items > 0
arg = args pop-front
if arg == "circumvent-boxing"
circumvent-boxing = true
else if arg == "level:"
arg = args pop-front
if arg != nil
level = arg int

# Run the benchmark.
bench = BenchObject new
start-time = System milliseconds
num-sends = bench nfibs: 33
num-sends = 0
iff targeting-c
if circumvent-boxing
num-sends = bench cnfibs: level
else
num-sends = bench nfibs: level
iff !targeting-c
num-sends = bench nfibs: level
time = System milliseconds - start-time
print-line: "nfibs: 33 = " + num-sends string
print-line: time string + " milliseconds"

# Report the results.
send: ("nfibs: ", level, " => ", num-sends, " sends.")
send: (time, " milliseconds.")
sends-per-second = num-sends float / (time float / 1000.0)
if sends-per-second > 1000000.0
send: (sends-per-second / 1000000.0, " MILLION sends per second.")
Expand Down

0 comments on commit c1b9f5f

Please sign in to comment.