Skip to content

Commit

Permalink
Don't force linear complexity and fix CI failure for old clang versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland authored and NAThompson committed Feb 6, 2022
1 parent 6546e3a commit 55b9607
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
27 changes: 7 additions & 20 deletions reporting/performance/color_tables_performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,22 @@
#include <boost/math/tools/color_maps.hpp>
#include <benchmark/benchmark.h>

template <typename Table, typename Dist, typename Gen>
int helper(const Table& table, Dist d, Gen gen, std::int64_t size)
{
for (std::int64_t i = 0; i < size; ++i)
{
table(d(gen));
}

return 0;
}

template <typename T>
template <typename Real>
void color_table_benchmark(benchmark::State& state)
{
std::random_device rd;
std::mt19937_64 gen(rd());
std::uniform_real_distribution<T> dist(0, 1);
std::uniform_real_distribution<Real> dist(0, 0.125);
constexpr boost::math::tools::smooth_cool_warm_color_map smooth_cool_warm;
const std::int64_t size = state.range(0);

Real x = dist(gen);
for (auto _ : state)
{
benchmark::DoNotOptimize(helper(smooth_cool_warm, dist, gen, size));
benchmark::DoNotOptimize(smooth_cool_warm(x));
x += std::numeric_limits<Real>::epsilon();
}
state.SetComplexityN(state.range(0));
}

BENCHMARK_TEMPLATE(color_table_benchmark, float)->RangeMultiplier(2)->Range(1 << 6, 1 << 20)->Complexity(benchmark::oN)->UseRealTime();
BENCHMARK_TEMPLATE(color_table_benchmark, double)->RangeMultiplier(2)->Range(1 << 6, 1 << 20)->Complexity(benchmark::oN)->UseRealTime();
BENCHMARK_TEMPLATE(color_table_benchmark, long double)->RangeMultiplier(2)->Range(1 << 6, 1 << 20)->Complexity(benchmark::oN)->UseRealTime();
BENCHMARK_TEMPLATE(color_table_benchmark, float);
BENCHMARK_TEMPLATE(color_table_benchmark, double);

BENCHMARK_MAIN();
7 changes: 7 additions & 0 deletions test/color_maps_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void test()
static_assert(user_plasma(0.5)[0] == plasma(0.5)[0]);
}

#if !defined(BOOST_MATH_NO_CONSTEXPR_DETECTION) && !defined(BOOST_MATH_USING_BUILTIN_CONSTANT_P)
int main()
{
test<float>();
Expand All @@ -32,3 +33,9 @@ int main()

return 0;
}
#else
int main()
{
return 0;
}
#endif

0 comments on commit 55b9607

Please sign in to comment.