-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench.fs
31 lines (26 loc) · 1.01 KB
/
bench.fs
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
let mutable times = []
let main file arg ()=
let w = System.Diagnostics.Stopwatch.StartNew()
let proc = new System.Diagnostics.Process()
proc.StartInfo.UseShellExecute <- false
proc.StartInfo.RedirectStandardOutput <- true
proc.StartInfo.Arguments <- arg
proc.StartInfo.FileName <- file
proc.Start() |> ignore
let mutable count = 0
let buf = Array.create 10000 'a'
while count < 100000 do
count <- count + proc.StandardOutput.ReadBlock(buf,0,9999)
proc.Kill()
w.Stop()
let time = w.ElapsedTicks
times <- (time|>float)::times
let bmark file arg comment () =
times <- []
[0..2] |> List.iter (fun t -> main file arg ())
let average = times |> List.average
printfn "average for %s" comment
printfn "%f ticks = %f kticks = %fMticks" average (average /1000.0) (average / (1000.0*1000.0))
//bmark "interp.exe" "" "asm interpreter" ()
//bmark "mono" "--optimize=all fsharp_interp.exe" "Fsharp interpreter" ()
bmark "asm.exe" "" "compiled asm" ()