33ce74593a4db918a013dfeafaeceaba0fb5ec0b
[master-thesis.git] / Parasitemia / Tests / ParasitemiaCore.Benchmark / EllipsesBench.fs
1 module ParasitemiaCore.EllipsesBench
2
3 open System
4 open System.Diagnostics
5 open type System.Console
6
7 open ParasitemiaCore.Ellipse
8
9 let rng = System.Random (42)
10
11 let generateParameters () : float * float * float * float * float * float * float * float =
12 rng.NextDouble (),
13 rng.NextDouble (),
14 rng.NextDouble (),
15 rng.NextDouble (),
16 rng.NextDouble (),
17 rng.NextDouble (),
18 rng.NextDouble (),
19 rng.NextDouble ()
20
21 let benchOld () =
22 let sw = Stopwatch ()
23 sw.Start ()
24
25 for i in 1 .. 500_000 do
26 let p1x, p1y, m1, p2x, p2y, m2, p3x, p3y = generateParameters ()
27 ellipse p1x p1y m1 p2x p2y m2 p3x p3y |> ignore
28
29 sw.Stop ()
30 WriteLine (sprintf "Old: time = %A ms" sw.ElapsedMilliseconds)
31
32
33 let benchNew () =
34 let sw = Stopwatch ()
35 sw.Start ()
36
37 for i in 1 .. 500_000 do
38 let p1x, p1y, m1, p2x, p2y, m2, p3x, p3y = generateParameters ()
39 ellipse' p1x p1y m1 p2x p2y m2 p3x p3y |> ignore
40
41 sw.Stop ()
42 WriteLine (sprintf "New: time = %A ms" sw.ElapsedMilliseconds)