let min = -1_000.
let max = +1_000.
let windowSize = 10.
+ let nbPoints = 500_000
+ let n = 1_000
let rng = System.Random 42
let nextNumber (min : float) (max : float) =
let points =
[
- for i = 1 to 200_000 do
+ for i = 1 to nbPoints do
let x = nextNumber min max
let y = nextNumber min max
yield Point (x, y)
]
+ let sw = System.Diagnostics.Stopwatch ()
+ sw.Start ()
+
let tree = Tree.BuildTree points
- let mutable nb = 0
- for i = 1 to 1_000 do
+ sw.Stop ()
+ output.WriteLine (sprintf "Time to build = %A ms" sw.ElapsedMilliseconds)
+
+ sw.Restart ()
+
+ let mutable nbFound = 0
+ for i = 1 to n do
let minX = nextNumber min (max - windowSize)
let minY = nextNumber min (max - windowSize)
- nb <- nb + (tree.Search { minX = minX; maxX = minX + float32 windowSize; minY = minY; maxY = minY + float32 windowSize } |> List.length)
+ nbFound <- nbFound + (tree.Search { minX = minX; maxX = minX + float32 windowSize; minY = minY; maxY = minY + float32 windowSize } |> List.length)
- output.WriteLine (sprintf "nb: %A" nb)
+ sw.Stop ()
+ output.WriteLine (sprintf "nb found: %i. Time to search = %A ms" nbFound sw.ElapsedMilliseconds)
<package id="System.ValueTuple" version="4.4.0" targetFramework="net452" />
<package id="xunit" version="2.3.1" targetFramework="net452" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net452" />
- <package id="xunit.analyzers" version="0.7.0" targetFramework="net452" />
+ <package id="xunit.analyzers" version="0.8.0" targetFramework="net452" />
<package id="xunit.assert" version="2.3.1" targetFramework="net452" />
<package id="xunit.core" version="2.3.1" targetFramework="net452" />
<package id="xunit.extensibility.core" version="2.3.1" targetFramework="net452" />