-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBenchmark.fs
82 lines (69 loc) · 2.12 KB
/
Benchmark.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// This file was created manually and its version is 1.0.0.
// This file supports running the performance benchmarks. Do not modify it.
module TreeBuildingBenchmark
open BenchmarkDotNet.Attributes
open TreeBuildingTypes
let inline run buildTree inputs =
for input in inputs do
buildTree input |> ignore
[<MemoryDiagnoser>]
[<InProcess>]
type Benchmarks () =
let oneNode =
[
{ RecordId = 0; ParentId = 0 }
]
let threeNodesInOrder =
[
{ RecordId = 0; ParentId = 0 };
{ RecordId = 1; ParentId = 0 };
{ RecordId = 2; ParentId = 0 };
]
let threeNodesInReverseOrder =
[
{ RecordId = 2; ParentId = 0 };
{ RecordId = 1; ParentId = 0 };
{ RecordId = 0; ParentId = 0 };
]
let moreThanTwoChildren =
[
{ RecordId = 3; ParentId = 0 };
{ RecordId = 2; ParentId = 0 };
{ RecordId = 1; ParentId = 0 };
{ RecordId = 0; ParentId = 0 };
]
let binaryTree =
[
{ RecordId = 5; ParentId = 1 };
{ RecordId = 3; ParentId = 2 };
{ RecordId = 2; ParentId = 0 };
{ RecordId = 4; ParentId = 1 };
{ RecordId = 1; ParentId = 0 };
{ RecordId = 0; ParentId = 0 };
{ RecordId = 6; ParentId = 2 }
]
let unbalancedTree =
[
{ RecordId = 5; ParentId = 2 };
{ RecordId = 3; ParentId = 2 };
{ RecordId = 2; ParentId = 0 };
{ RecordId = 4; ParentId = 1 };
{ RecordId = 1; ParentId = 0 };
{ RecordId = 0; ParentId = 0 };
{ RecordId = 6; ParentId = 2 }
]
let inputs =
[
oneNode
threeNodesInOrder
threeNodesInReverseOrder
moreThanTwoChildren
binaryTree
unbalancedTree
]
[<Benchmark(Baseline = true)>]
member __.Baseline () =
inputs |> run TreeBuildingBaseline.buildTree
[<Benchmark>]
member __.Mine () =
inputs |> run TreeBuilding.buildTree