-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleBench.fs
More file actions
35 lines (29 loc) · 921 Bytes
/
Copy pathExampleBench.fs
File metadata and controls
35 lines (29 loc) · 921 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
namespace ExampleBenchmark
open SharpBench.Core
module BenchModule =
[<Bench("NoOp")>]
let noop () =
()
[<Bench("List Initialization")>]
let fwithobjs () =
List.init 1000 id |> ignore
[<Bench("Naive Fibonacci(17)")>]
let fnoobjs () =
let rec fib x =
if x < 1 then
x
else
fib (x-1) + fib (x-2)
fib 17 |> ignore
let mutable size = 0.0
[<Bench("Function which takes longer and longer as you call it")>]
let sidef () =
List.init (int(size)) id |> ignore
size <- size + 0.01
let proc = System.Diagnostics.Process.GetCurrentProcess()
[<Bench("Function with inconsistent timing")>]
let noisyf () =
let t = proc.TotalProcessorTime.TotalMilliseconds
let s = t + 0.03 * float(1 + proc.TotalProcessorTime.Seconds % 2)
while proc.TotalProcessorTime.TotalMilliseconds < s do
()