From: Greg Burri Date: Thu, 10 May 2018 18:47:07 +0000 (+0200) Subject: Update KdTree tests. X-Git-Tag: 1.0.13~13 X-Git-Url: http://git.euphorik.ch/?a=commitdiff_plain;h=cfe1a48a381984c6259601abb93fabaf266190fb;p=master-thesis.git Update KdTree tests. --- diff --git a/Parasitemia/Tests/ParasitemiaCore.Tests/KdTreeTests.fs b/Parasitemia/Tests/ParasitemiaCore.Tests/KdTreeTests.fs index 929dd9e..614640d 100644 --- a/Parasitemia/Tests/ParasitemiaCore.Tests/KdTreeTests.fs +++ b/Parasitemia/Tests/ParasitemiaCore.Tests/KdTreeTests.fs @@ -71,6 +71,8 @@ type KdTreeTests (output : ITestOutputHelper) = 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) = @@ -78,21 +80,30 @@ type KdTreeTests (output : ITestOutputHelper) = 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) diff --git a/Parasitemia/Tests/ParasitemiaCore.Tests/packages.config b/Parasitemia/Tests/ParasitemiaCore.Tests/packages.config index 048399b..4ffcb24 100644 --- a/Parasitemia/Tests/ParasitemiaCore.Tests/packages.config +++ b/Parasitemia/Tests/ParasitemiaCore.Tests/packages.config @@ -4,7 +4,7 @@ - +