-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
42 lines (38 loc) · 1.53 KB
/
main.cpp
File metadata and controls
42 lines (38 loc) · 1.53 KB
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
#include <benchmark/benchmark.h>
#include "poisson.h"
using namespace poisson;
static void BM_poisson(benchmark::State& s)
{
struct MyFilter : public PoissonDiskMultiSampler::RealFunction2D
{
MyFilter(){}
virtual bool placeObject(int layerIndex, float x, float y)
{
// NB. this is a callback you can register with the sampler to filter out placed objects
return true;
}
};
MyFilter distribution;
std::vector<float> minDist = { 4.f, 12.f, 36.f };
std::vector<float> minRadi = { 1.f, 3.f, 9.f };
std::vector<float> maxRadi = { 2.f, 6.f, 18.f };
for(auto _ : s)
{
int tileSize = static_cast<int>(s.range(0));
PoissonDiskMultiSampler sampler(-(tileSize / 2.f),
-(tileSize / 2.f),
(tileSize / 2.f),
(tileSize / 2.f),
minDist,
minRadi,
maxRadi,
5*tileSize, // NB. set to zero to fill until full
distribution,
minDist.size() > 1,
10);
PoissonDiskMultiSampler::PointListArray layers;
sampler.sample(layers);
}
}
BENCHMARK(BM_poisson)->Unit(benchmark::kMillisecond)->RangeMultiplier(2)->Range(8, 8<<6);
BENCHMARK_MAIN();