-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathRunBenchmarks.lean
More file actions
36 lines (31 loc) · 915 Bytes
/
RunBenchmarks.lean
File metadata and controls
36 lines (31 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Veir
def count := 50_000
def getCountFrom (c : Option String) :=
match c with
| none => count
| some s =>
match s.toNat? with
| none => count
| some n => n
def getPCFrom (c : Option String) :=
match c with
| none => 100
| some s =>
match s.toNat? with
| none => 100
| some n => n
def bench (f: IO Unit) (count : Nat) : IO Unit := do
let startTime ← IO.monoMsNow
f
let endTime ← IO.monoMsNow
let elapsedTime := endTime - startTime
IO.println s!"Elapsed time: {elapsedTime} miliseconds"
IO.println s!"ns per op : {(elapsedTime * 1000 * 1000) / count}"
def main (args : List String) : IO Unit := do
IO.println s!"Benchmark ({args})"
let count := getCountFrom args[1]?
if let some bench := args[0]? then
Veir.Benchmarks.runBenchmark bench count (getPCFrom args[2]?)
else
IO.eprintln "Please provide a benchmark name"
IO.Process.exit 2