FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
delaunator-cpp/bench/run.cpp at master · abellgithub/delaunator-cpp · GitHub
abellgithub
/
delaunator-cpp
Public
Notifications
You must be signed in to change notification settings
Fork
35
Star
212
Code
Issues
3
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
delaunator-cpp
/
bench
/
run.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
94 lines (81 loc) · 2.61 KB
Breadcrumbs
delaunator-cpp
/
bench
/
run.cpp
Copy path
File metadata and controls
94 lines (81 loc) · 2.61 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#
include
"
../examples/utils.hpp
"
#
include
<
benchmark/benchmark.h
>
#
include
<
delaunator.hpp
>
#
include
<
random
>
#
include
<
string
>
#
include
<
vector
>
#
include
<
iostream
>
std::vector<
double
>
generate_uniform
(std::
size_t
n) {
std::vector<
double
> coords;
coords.
reserve
(
2
* n);
std::srand
(
350
);
double
norm =
static_cast
<
double
>(
RAND_MAX
) /
1e3
;
for
(
size_t
i =
0
; i < n; i++) {
coords.
push_back
(
static_cast
<
double
>(
std::rand
()) / norm);
coords.
push_back
(
static_cast
<
double
>(
std::rand
()) / norm);
}
return
coords;
}
void
BM_45K_geojson_nodes
(benchmark::State& state) {
std::string points_str =
utils::read_file
(
"
./test-files/osm-nodes-45331-epsg-3857.geojson
"
);
std::vector<
double
> coords =
utils::get_geo_json_points
(points_str);
while
(state.
KeepRunning
()) {
delaunator::Delaunator
delaunator
(coords);
}
}
void
BM_uniform
(benchmark::State& state) {
std::vector<
double
> coords =
generate_uniform
(
static_cast
<std::
size_t
>(state.
range
(
0
)));
while
(state.
KeepRunning
()) {
delaunator::Delaunator
delaunator
(coords);
}
state.
SetComplexityN
(state.
range
(
0
));
}
class
MyFixture
: public ::benchmark::Fixture
{
public:
MyFixture
() : vals(generate_uniform(
10000000
))
{
}
virtual
void
SetUp
(::benchmark::State&)
{}
virtual
void
TearDown
(::benchmark::State&)
{}
std::vector<
double
> vals;
};
/*
*
BENCHMARK_DEFINE_F(MyFixture, minmax)(::benchmark::State&state)
{
std::cerr << "vals size = " << vals.size() << "!\n";
double mn = std::numeric_limits<double>::max();
double mx = std::numeric_limits<double>::lowest();
while (state.KeepRunning())
{
for (int i = 0; i < 100; ++i)
{
for (double& v : vals)
{
mn = std::min(mn, v);
mx = std::max(mx, v);
if (v < mn)
mn = v;
if (v > mx)
mx = v;
}
}
}
std::cerr << "MIN/MAX = " << mn << "/" << mx << "!\n";
}
BENCHMARK_REGISTER_F(MyFixture, minmax)->Unit(benchmark::kMillisecond);
*
*/
BENCHMARK
(BM_45K_geojson_nodes)->
Unit
(benchmark::
kMillisecond
);
BENCHMARK
(BM_uniform)->
Arg
(
2000
)->Arg(
100000
)->Arg(
200000
)->Arg(
500000
)->Arg(
1000000
)->Unit(benchmark::
kMillisecond
);
#
if
BENCHMARK_BIG_O
BENCHMARK
(BM_uniform)->
RangeMultiplier
(
2
)->Range(
1
<<
12
,
1
<<
22
)->Unit(benchmark::
kMillisecond
)->Complexity();
#
endif
#
if
BENCHMARK_10M
BENCHMARK
(BM_uniform)->
Arg
(
1000000
*
10
)->Unit(benchmark::
kMillisecond
);
#
endif
#
if
BENCHMARK_100M
BENCHMARK
(BM_uniform)->
Arg
(
1000000
*
100
)->Unit(benchmark::
kMillisecond
);
#
endif
BENCHMARK_MAIN
()
Back
|
FazBrowse Home
|
New Git URL