Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions core/src/walltime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -63,8 +60,7 @@ double compute_quantile(const std::vector<double> &data, double quantile) {
}

void compute_iqr_and_outliers(const std::vector<double> &times_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<double> sorted_times = times_ns;
Expand Down Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions examples/google_benchmark_bazel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cc_binary(
name = "my_benchmark",
srcs = glob(["*.cpp", "*.hpp"]),
copts = ["-Wall", "-Wextra", "-Werror"],
deps = [
"//google_benchmark:benchmark",
],
Expand Down
5 changes: 5 additions & 0 deletions examples/google_benchmark_cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
21 changes: 12 additions & 9 deletions examples/google_benchmark_cmake/fixture_bench.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
#ifndef FIXTURE_BENCH_HPP
#define FIXTURE_BENCH_HPP


#include <benchmark/benchmark.h>

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) {
Expand All @@ -28,7 +27,8 @@ BENCHMARK_REGISTER_F(MyFixture, BarTest);
//
//

template <typename T> class MyTemplatedFixture : public benchmark::Fixture {};
template <typename T>
class MyTemplatedFixture : public benchmark::Fixture {};
BENCHMARK_TEMPLATE_F(MyTemplatedFixture, IntTest, int)(benchmark::State &st) {
for (auto _ : st) {
}
Expand All @@ -43,7 +43,8 @@ BENCHMARK_REGISTER_F(MyTemplatedFixture, DoubleTest);
//
//

template <typename T> class MyTemplate1 : public benchmark::Fixture {};
template <typename T>
class MyTemplate1 : public benchmark::Fixture {};
BENCHMARK_TEMPLATE1_DEFINE_F(MyTemplate1, TestA, int)(benchmark::State &st) {
for (auto _ : st) {
}
Expand All @@ -53,13 +54,15 @@ BENCHMARK_REGISTER_F(MyTemplate1, TestA);
//
//

template <typename T, typename U> class MyTemplate2 : public benchmark::Fixture {};
BENCHMARK_TEMPLATE2_DEFINE_F(MyTemplate2, TestB, int, double)(benchmark::State &st) {
template <typename T, typename U>
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
10 changes: 6 additions & 4 deletions examples/google_benchmark_cmake/main.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#include "fixture_bench.hpp"
#include "template_bench.hpp"
#include <benchmark/benchmark.h>

#include <cstring>

#include "fixture_bench.hpp"
#include "template_bench.hpp"

template <class... Args>
void BM_Capture(benchmark::State &state, Args &&...args) {
auto args_tuple = std::make_tuple(std::move(args)...);
(void)args_tuple;
for (auto _ : state) {
}
}
Expand Down Expand Up @@ -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;
}
Expand Down
Loading