add benchmark for mapnik::util::normalize_angle
This commit is contained in:
parent
5091a4ba9d
commit
d70c2d978c
2 changed files with 70 additions and 0 deletions
|
@ -28,6 +28,7 @@ run test_expression_parse 10 10000
|
||||||
run test_face_ptr_creation 10 1000
|
run test_face_ptr_creation 10 1000
|
||||||
run test_font_registration 10 100
|
run test_font_registration 10 100
|
||||||
run test_offset_converter 10 1000
|
run test_offset_converter 10 1000
|
||||||
|
#run normalize_angle 0 1000000 --min-duration=0.2
|
||||||
|
|
||||||
# commented since this is really slow on travis
|
# commented since this is really slow on travis
|
||||||
: '
|
: '
|
||||||
|
|
69
benchmark/src/normalize_angle.cpp
Normal file
69
benchmark/src/normalize_angle.cpp
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
#include "bench_framework.hpp"
|
||||||
|
|
||||||
|
#include <mapnik/util/math.hpp>
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct bench_func : benchmark::test_case
|
||||||
|
{
|
||||||
|
T (* const func_)(T);
|
||||||
|
T const value_;
|
||||||
|
|
||||||
|
bench_func(mapnik::parameters const& params, T (*func)(T), T value)
|
||||||
|
: test_case(params), func_(func), value_(value) {}
|
||||||
|
|
||||||
|
bool validate() const { return true; }
|
||||||
|
|
||||||
|
bool operator() () const
|
||||||
|
{
|
||||||
|
for (auto i = this->iterations_; i-- > 0; )
|
||||||
|
{
|
||||||
|
func_(value_);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define BENCH_FUNC1(func, value) \
|
||||||
|
run<bench_func<double>>(#func "(" #value ")", func, value)
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
return benchmark::sequencer(argc, argv)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +3)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +6)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +9)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +12)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +15)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +20)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +30)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +40)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +50)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +70)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +90)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +110)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +130)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +157)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +209)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +314)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +628)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, +942)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -3)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -6)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -9)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -12)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -15)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -20)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -30)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -40)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -50)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -70)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -90)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -110)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -130)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -157)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -209)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -314)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -628)
|
||||||
|
.BENCH_FUNC1(mapnik::util::normalize_angle, -942)
|
||||||
|
.done();
|
||||||
|
}
|
Loading…
Reference in a new issue