Skip to content

Commit c139480

Browse files
committed
Add GetVoronoiCellsBenchmark
Add simple benchmark of GetVoronoiCells
1 parent af8a2c7 commit c139480

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using BenchmarkDotNet.Attributes;
2+
using BenchmarkDotNet.Engines;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
6+
namespace DelaunatorSharp.Benchmark
7+
{
8+
[SimpleJob(RunStrategy.ColdStart, warmupCount:10, targetCount: 10)]
9+
[HtmlExporter]
10+
public class GetVoronoiCellsBenchmark
11+
{
12+
private Distribution distribution = new Distribution();
13+
private IPoint[] points;
14+
15+
[Params(5000)]
16+
public int Count;
17+
18+
[ParamsAllValues]
19+
public Distribution.Type Type { get; set; }
20+
21+
private Delaunator delaunator;
22+
23+
[GlobalSetup]
24+
public void GlobalSetup()
25+
{
26+
points = distribution.GetPoints(Type, Count).ToArray();
27+
delaunator = new Delaunator(points);
28+
}
29+
30+
[Benchmark]
31+
public void GetVoronoiCells()
32+
{
33+
using var enumerator = delaunator.GetVoronoiCells().GetEnumerator();
34+
while (enumerator.MoveNext()) { }
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)