mirror of
https://github.com/boostorg/math.git
synced 2026-01-19 04:22:09 +00:00
Bivariate Stats Policies (#503)
* Add parallel impl and change seq impl [CI SKIP] * Validate seq impl [CI SKIP] * Remove old impl * Add user interfaces [CI SKIP] * Floating point covariance validated [CI SKIP] * Integer covariance validated [CI SKIP] * Change correlation_coeff impl interface [CI SKIP] * Cleanup [CI SKIP] * correlation passes all parameters for par impl [CI SKIP] * Finish framework [CI SKIP] * Add correlation coefficient test cases * Add benchmark and make small changes [CI SKIP] * Update docs
This commit is contained in:
79
reporting/performance/bivariate_statistics_performance.cpp
Normal file
79
reporting/performance/bivariate_statistics_performance.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
// (C) Copyright Matt Borland 2021.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <vector>
|
||||
#include <boost/math/tools/random_vector.hpp>
|
||||
#include <boost/math/statistics/bivariate_statistics.hpp>
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
using boost::math::generate_random_vector;
|
||||
|
||||
template<typename T>
|
||||
void seq_covariance(benchmark::State& state)
|
||||
{
|
||||
constexpr std::size_t seed {};
|
||||
const std::size_t size = state.range(0);
|
||||
std::vector<T> u = generate_random_vector<T>(size, seed);
|
||||
std::vector<T> v = generate_random_vector<T>(size, seed);
|
||||
|
||||
for(auto _ : state)
|
||||
{
|
||||
benchmark::DoNotOptimize(boost::math::statistics::covariance(std::execution::seq, u, v));
|
||||
}
|
||||
state.SetComplexityN(state.range(0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void par_covariance(benchmark::State& state)
|
||||
{
|
||||
constexpr std::size_t seed {};
|
||||
const std::size_t size = state.range(0);
|
||||
std::vector<T> u = generate_random_vector<T>(size, seed);
|
||||
std::vector<T> v = generate_random_vector<T>(size, seed);
|
||||
|
||||
for(auto _ : state)
|
||||
{
|
||||
benchmark::DoNotOptimize(boost::math::statistics::covariance(std::execution::par, u, v));
|
||||
}
|
||||
state.SetComplexityN(state.range(0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void seq_correlation(benchmark::State& state)
|
||||
{
|
||||
constexpr std::size_t seed {};
|
||||
const std::size_t size = state.range(0);
|
||||
std::vector<T> u = generate_random_vector<T>(size, seed);
|
||||
std::vector<T> v = generate_random_vector<T>(size, seed);
|
||||
|
||||
for(auto _ : state)
|
||||
{
|
||||
benchmark::DoNotOptimize(boost::math::statistics::correlation_coefficient(std::execution::seq, u, v));
|
||||
}
|
||||
state.SetComplexityN(state.range(0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void par_correlation(benchmark::State& state)
|
||||
{
|
||||
constexpr std::size_t seed {};
|
||||
const std::size_t size = state.range(0);
|
||||
std::vector<T> u = generate_random_vector<T>(size, seed);
|
||||
std::vector<T> v = generate_random_vector<T>(size, seed);
|
||||
|
||||
for(auto _ : state)
|
||||
{
|
||||
benchmark::DoNotOptimize(boost::math::statistics::correlation_coefficient(std::execution::par, u, v));
|
||||
}
|
||||
state.SetComplexityN(state.range(0));
|
||||
}
|
||||
|
||||
BENCHMARK_TEMPLATE(seq_covariance, double)->RangeMultiplier(2)->Range(1 << 6, 1 << 20)->Complexity(benchmark::oN)->UseRealTime();
|
||||
BENCHMARK_TEMPLATE(par_covariance, double)->RangeMultiplier(2)->Range(1 << 6, 1 << 20)->Complexity(benchmark::oN)->UseRealTime();
|
||||
|
||||
BENCHMARK_TEMPLATE(seq_correlation, double)->RangeMultiplier(2)->Range(1 << 6, 1 << 20)->Complexity(benchmark::oN)->UseRealTime();
|
||||
BENCHMARK_TEMPLATE(par_correlation, double)->RangeMultiplier(2)->Range(1 << 6, 1 << 20)->Complexity(benchmark::oN)->UseRealTime();
|
||||
|
||||
BENCHMARK_MAIN();
|
||||
Reference in New Issue
Block a user