diff --git a/core/src/walltime.cpp b/core/src/walltime.cpp index 0dfa80c..23b8c4b 100644 --- a/core/src/walltime.cpp +++ b/core/src/walltime.cpp @@ -18,9 +18,6 @@ namespace codspeed { -const double IQR_OUTLIER_FACTOR = 1.5; -const double STDEV_OUTLIER_FACTOR = 3.0; - // Times are per iteration struct BenchmarkStats { double min_ns; @@ -63,8 +60,7 @@ double compute_quantile(const std::vector &data, double quantile) { } void compute_iqr_and_outliers(const std::vector ×_ns, double mean, - double median, double stdev, double &q1, - double &q3, double &iqr, + double stdev, double &q1, double &q3, double &iqr, size_t &iqr_outlier_rounds, size_t &stdev_outlier_rounds) { std::vector sorted_times = times_ns; @@ -217,9 +213,8 @@ void generate_codspeed_walltime_report( double stdev = raw_benchmark.stdev_ns; double q1, q3, iqr; size_t iqr_outlier_rounds, stdev_outlier_rounds; - compute_iqr_and_outliers(raw_benchmark.round_times_ns, mean, median, stdev, - q1, q3, iqr, iqr_outlier_rounds, - stdev_outlier_rounds); + compute_iqr_and_outliers(raw_benchmark.round_times_ns, mean, stdev, q1, q3, + iqr, iqr_outlier_rounds, stdev_outlier_rounds); // Populate stats codspeed_benchmark.stats = { diff --git a/examples/google_benchmark_bazel/BUILD.bazel b/examples/google_benchmark_bazel/BUILD.bazel index d30cce5..444a4dc 100644 --- a/examples/google_benchmark_bazel/BUILD.bazel +++ b/examples/google_benchmark_bazel/BUILD.bazel @@ -1,6 +1,7 @@ cc_binary( name = "my_benchmark", srcs = glob(["*.cpp", "*.hpp"]), + copts = ["-Wall", "-Wextra", "-Werror"], deps = [ "//google_benchmark:benchmark", ], diff --git a/examples/google_benchmark_cmake/CMakeLists.txt b/examples/google_benchmark_cmake/CMakeLists.txt index f8f8fc4..3d3067a 100644 --- a/examples/google_benchmark_cmake/CMakeLists.txt +++ b/examples/google_benchmark_cmake/CMakeLists.txt @@ -3,6 +3,11 @@ include(FetchContent) project(codspeed_picobench_compat VERSION 0.0.0 LANGUAGES CXX) +# Treat warnings as errors +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + add_compile_options(-Wall -Wextra -Werror) +endif() + # On the small benchmarks of this repo, most of the benches will be optimized out, but this is expected. set(CMAKE_BUILD_TYPE RelWithDebInfo) diff --git a/examples/google_benchmark_cmake/fixture_bench.hpp b/examples/google_benchmark_cmake/fixture_bench.hpp index 738ba31..ff2d4e3 100644 --- a/examples/google_benchmark_cmake/fixture_bench.hpp +++ b/examples/google_benchmark_cmake/fixture_bench.hpp @@ -4,16 +4,15 @@ #ifndef FIXTURE_BENCH_HPP #define FIXTURE_BENCH_HPP - #include namespace example_namespace { class MyFixture : public benchmark::Fixture { -public: - void SetUp(::benchmark::State &state) {} + public: + void SetUp(::benchmark::State &state) { (void)state; } - void TearDown(::benchmark::State &state) {} + void TearDown(::benchmark::State &state) { (void)state; } }; BENCHMARK_F(MyFixture, FooTest)(benchmark::State &st) { for (auto _ : st) { @@ -28,7 +27,8 @@ BENCHMARK_REGISTER_F(MyFixture, BarTest); // // -template class MyTemplatedFixture : public benchmark::Fixture {}; +template +class MyTemplatedFixture : public benchmark::Fixture {}; BENCHMARK_TEMPLATE_F(MyTemplatedFixture, IntTest, int)(benchmark::State &st) { for (auto _ : st) { } @@ -43,7 +43,8 @@ BENCHMARK_REGISTER_F(MyTemplatedFixture, DoubleTest); // // -template class MyTemplate1 : public benchmark::Fixture {}; +template +class MyTemplate1 : public benchmark::Fixture {}; BENCHMARK_TEMPLATE1_DEFINE_F(MyTemplate1, TestA, int)(benchmark::State &st) { for (auto _ : st) { } @@ -53,13 +54,15 @@ BENCHMARK_REGISTER_F(MyTemplate1, TestA); // // -template class MyTemplate2 : public benchmark::Fixture {}; -BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int, double)(benchmark::State &st) { +template +class MyTemplate2 : public benchmark::Fixture {}; +BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int, + double)(benchmark::State &st) { for (auto _ : st) { } } BENCHMARK_REGISTER_F(MyTemplate2, TestB); -} +} // namespace example_namespace #endif diff --git a/examples/google_benchmark_cmake/main.cpp b/examples/google_benchmark_cmake/main.cpp index 496ae3f..035ae45 100644 --- a/examples/google_benchmark_cmake/main.cpp +++ b/examples/google_benchmark_cmake/main.cpp @@ -1,11 +1,14 @@ -#include "fixture_bench.hpp" -#include "template_bench.hpp" #include + #include +#include "fixture_bench.hpp" +#include "template_bench.hpp" + template void BM_Capture(benchmark::State &state, Args &&...args) { auto args_tuple = std::make_tuple(std::move(args)...); + (void)args_tuple; for (auto _ : state) { } } @@ -36,8 +39,7 @@ static void BM_memcpy(benchmark::State &state) { char *src = new char[state.range(0)]; char *dst = new char[state.range(0)]; memset(src, 'x', state.range(0)); - for (auto _ : state) - memcpy(dst, src, state.range(0)); + for (auto _ : state) memcpy(dst, src, state.range(0)); delete[] src; delete[] dst; }