cb66c5d68e
build-and-test / ubuntu-24.04-arm.Debug.static.clang++ (push) Waiting to run
build-and-test / macos-latest.Debug.shared.g++ (push) Waiting to run
build-and-test / macos-latest.Debug.static.g++ (push) Waiting to run
build-and-test / ubuntu-22.04.Debug.static.g++ (push) Waiting to run
build-and-test / ubuntu-24.04.Debug.static.g++ (push) Waiting to run
bazel / bazel.macos-latest (push) Waiting to run
bazel / bazel.windows-latest (push) Waiting to run
build-and-test-min-cmake / macos-latest.min-cmake (push) Waiting to run
build-and-test / macos-latest.Debug.shared.clang++ (push) Waiting to run
build-and-test / ubuntu-22.04.Debug.shared.clang++ (push) Waiting to run
build-and-test / ubuntu-24.04.Debug.shared.clang++ (push) Waiting to run
build-and-test / ubuntu-24.04-arm.Debug.shared.clang++ (push) Waiting to run
build-and-test / macos-latest.Debug.static.clang++ (push) Waiting to run
build-and-test / ubuntu-22.04.Debug.static.clang++ (push) Waiting to run
build-and-test / ubuntu-24.04.Debug.static.clang++ (push) Waiting to run
build-and-test / ubuntu-22.04.Debug.shared.g++ (push) Waiting to run
build-and-test / ubuntu-24.04.Debug.shared.g++ (push) Waiting to run
build-and-test / ubuntu-24.04-arm.Debug.shared.g++ (push) Waiting to run
build-and-test / ubuntu-24.04-arm.Debug.static.g++ (push) Waiting to run
build-and-test / macos-latest.Release.shared.clang++ (push) Waiting to run
build-and-test / ubuntu-22.04.Release.shared.clang++ (push) Waiting to run
build-and-test / ubuntu-24.04.Release.shared.clang++ (push) Waiting to run
build-and-test / ubuntu-24.04-arm.Release.shared.clang++ (push) Waiting to run
build-and-test / macos-latest.Release.static.clang++ (push) Waiting to run
build-and-test / ubuntu-22.04.Release.static.clang++ (push) Waiting to run
build-and-test / ubuntu-24.04.Release.static.clang++ (push) Waiting to run
build-and-test / ubuntu-24.04-arm.Release.static.clang++ (push) Waiting to run
build-and-test / macos-latest.Release.shared.g++ (push) Waiting to run
build-and-test / ubuntu-22.04.Release.shared.g++ (push) Waiting to run
build-and-test / ubuntu-24.04.Release.shared.g++ (push) Waiting to run
build-and-test / ubuntu-24.04-arm.Release.shared.g++ (push) Waiting to run
build-and-test / macos-latest.Release.static.g++ (push) Waiting to run
build-and-test / ubuntu-22.04.Release.static.g++ (push) Waiting to run
build-and-test / ubuntu-24.04.Release.static.g++ (push) Waiting to run
build-and-test / ubuntu-24.04-arm.Release.static.g++ (push) Waiting to run
build-and-test / windows-2022.Debug.shared.VS-17-2022 (push) Waiting to run
build-and-test / windows-2022.Debug.static.VS-17-2022 (push) Waiting to run
build-and-test / windows-2025.Debug.shared.VS-18-2025 (push) Waiting to run
build-and-test / windows-2025.Debug.static.VS-18-2025 (push) Waiting to run
build-and-test / windows-2022.Release.shared.VS-17-2022 (push) Waiting to run
build-and-test / windows-2022.Release.static.VS-17-2022 (push) Waiting to run
build-and-test / windows-2025.Release.shared.VS-18-2025 (push) Waiting to run
build-and-test / windows-2025.Release.static.VS-18-2025 (push) Waiting to run
build-and-test / windows-latest.Debug.shared.CLANG64 (push) Waiting to run
build-and-test / windows-latest.Debug.shared.MINGW64 (push) Waiting to run
build-and-test / windows-latest.Debug.shared.UCRT64 (push) Waiting to run
build-and-test / windows-latest.Debug.static.CLANG64 (push) Waiting to run
build-and-test / windows-latest.Debug.static.MINGW64 (push) Waiting to run
build-and-test / windows-latest.Debug.static.UCRT64 (push) Waiting to run
build-and-test / windows-latest.Release.shared.CLANG64 (push) Waiting to run
build-and-test / windows-latest.Release.shared.MINGW64 (push) Waiting to run
build-and-test / windows-latest.Release.shared.UCRT64 (push) Waiting to run
build-and-test / windows-latest.Release.static.CLANG64 (push) Waiting to run
build-and-test / windows-latest.Release.static.MINGW64 (push) Waiting to run
build-and-test / windows-latest.Release.static.UCRT64 (push) Waiting to run
test-bindings / Test Python 3.10 bindings on macos-latest (push) Waiting to run
test-bindings / Test Python 3.11 bindings on macos-latest (push) Waiting to run
test-bindings / Test Python 3.12 bindings on macos-latest (push) Waiting to run
test-bindings / Test Python 3.13 bindings on macos-latest (push) Waiting to run
test-bindings / Test Python 3.10 bindings on windows-latest (push) Waiting to run
test-bindings / Test Python 3.11 bindings on windows-latest (push) Waiting to run
test-bindings / Test Python 3.12 bindings on windows-latest (push) Waiting to run
test-bindings / Test Python 3.13 bindings on windows-latest (push) Waiting to run
test-bindings / Test Rust bindings on macos-latest (push) Waiting to run
test-bindings / Test Rust bindings on windows-latest (push) Waiting to run
bazel / bazel.ubuntu-latest (push) Failing after 1s
build-and-test-perfcounters / ubuntu-latest.Debug (push) Failing after 0s
build-and-test-perfcounters / ubuntu-latest.Release (push) Failing after 1s
doxygen / Build HTML documentation (push) Failing after 1s
python + Bazel pre-commit checks / pre-commit (push) Failing after 1s
sanitizer / tsan.Debug (push) Failing after 1s
sanitizer / ubsan.Debug (push) Failing after 0s
sanitizer / ubsan.RelWithDebInfo (push) Failing after 1s
build-and-test-min-cmake / ubuntu-latest.min-cmake (push) Failing after 1s
clang-format-lint / check-clang-format (push) Failing after 1s
sanitizer / asan.Debug (push) Failing after 1s
sanitizer / msan.RelWithDebInfo (push) Failing after 1s
clang-tidy / run-clang-tidy (push) Failing after 1s
sanitizer / msan.Debug (push) Failing after 1s
sanitizer / asan.RelWithDebInfo (push) Failing after 0s
sanitizer / tsan.RelWithDebInfo (push) Failing after 0s
test-bindings / Test Rust bindings on ubuntu-latest (push) Failing after 0s
test-bindings / Test Python 3.10 bindings on ubuntu-latest (push) Failing after 0s
test-bindings / Test Python 3.11 bindings on ubuntu-latest (push) Failing after 0s
test-bindings / Test Python 3.12 bindings on ubuntu-latest (push) Failing after 1s
test-bindings / Test Python 3.13 bindings on ubuntu-latest (push) Failing after 0s
239 lines
6.3 KiB
C++
239 lines
6.3 KiB
C++
// Copyright 2015 Google Inc. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#ifndef BENCHMARK_REPORTER_H_
|
|
#define BENCHMARK_REPORTER_H_
|
|
|
|
#if defined(_MSC_VER)
|
|
#pragma warning(push)
|
|
// C4251: <symbol> needs to have dll-interface to be used by clients of class
|
|
#pragma warning(disable : 4251)
|
|
#endif
|
|
|
|
#include <cassert>
|
|
#include <iostream>
|
|
#include <set>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "benchmark/counter.h"
|
|
#include "benchmark/macros.h"
|
|
#include "benchmark/managers.h"
|
|
#include "benchmark/statistics.h"
|
|
#include "benchmark/sysinfo.h"
|
|
#include "benchmark/types.h"
|
|
|
|
namespace benchmark {
|
|
|
|
struct BENCHMARK_EXPORT BenchmarkName {
|
|
std::string function_name;
|
|
std::string args;
|
|
std::string min_time;
|
|
std::string min_warmup_time;
|
|
std::string iterations;
|
|
std::string repetitions;
|
|
std::string time_type;
|
|
std::string threads;
|
|
|
|
std::string str() const;
|
|
};
|
|
|
|
class BENCHMARK_EXPORT BenchmarkReporter {
|
|
public:
|
|
struct Context {
|
|
CPUInfo const& cpu_info;
|
|
SystemInfo const& sys_info;
|
|
size_t name_field_width = 0;
|
|
static const char* executable_name;
|
|
Context();
|
|
};
|
|
|
|
struct BENCHMARK_EXPORT Run {
|
|
static const int64_t no_repetition_index = -1;
|
|
enum RunType { RT_Iteration, RT_Aggregate };
|
|
|
|
Run()
|
|
: run_type(RT_Iteration),
|
|
aggregate_unit(kTime),
|
|
skipped(internal::NotSkipped),
|
|
iterations(1),
|
|
threads(1),
|
|
time_unit(kNanosecond),
|
|
real_accumulated_time(0),
|
|
cpu_accumulated_time(0),
|
|
max_heapbytes_used(0),
|
|
use_real_time_for_initial_big_o(false),
|
|
complexity(oNone),
|
|
complexity_lambda(),
|
|
complexity_n(0),
|
|
statistics(),
|
|
report_big_o(false),
|
|
report_rms(false),
|
|
allocs_per_iter(0.0) {}
|
|
|
|
std::string benchmark_name() const;
|
|
BenchmarkName run_name;
|
|
int64_t family_index;
|
|
int64_t per_family_instance_index;
|
|
RunType run_type;
|
|
std::string aggregate_name;
|
|
StatisticUnit aggregate_unit;
|
|
std::string report_label;
|
|
internal::Skipped skipped;
|
|
std::string skip_message;
|
|
|
|
IterationCount iterations;
|
|
int64_t threads;
|
|
int64_t repetition_index;
|
|
int64_t repetitions;
|
|
TimeUnit time_unit;
|
|
double real_accumulated_time;
|
|
double cpu_accumulated_time;
|
|
|
|
double GetAdjustedRealTime() const;
|
|
double GetAdjustedCPUTime() const;
|
|
|
|
double max_heapbytes_used;
|
|
bool use_real_time_for_initial_big_o;
|
|
BigO complexity;
|
|
BigOFunc* complexity_lambda;
|
|
ComplexityN complexity_n;
|
|
const std::vector<internal::Statistics>* statistics;
|
|
bool report_big_o;
|
|
bool report_rms;
|
|
UserCounters counters;
|
|
MemoryManager::Result memory_result;
|
|
double allocs_per_iter;
|
|
};
|
|
|
|
struct PerFamilyRunReports {
|
|
PerFamilyRunReports() : num_runs_total(0), num_runs_done(0) {}
|
|
int num_runs_total;
|
|
int num_runs_done;
|
|
std::vector<BenchmarkReporter::Run> Runs;
|
|
};
|
|
|
|
BenchmarkReporter();
|
|
virtual bool ReportContext(const Context& context) = 0;
|
|
virtual void ReportRunsConfig(double /*min_time*/,
|
|
bool /*has_explicit_iters*/,
|
|
IterationCount /*iters*/) {}
|
|
virtual void ReportRuns(const std::vector<Run>& report) = 0;
|
|
virtual void Finalize() {}
|
|
|
|
void SetOutputStream(std::ostream* out) {
|
|
assert(out);
|
|
output_stream_ = out;
|
|
}
|
|
void SetErrorStream(std::ostream* err) {
|
|
assert(err);
|
|
error_stream_ = err;
|
|
}
|
|
std::ostream& GetOutputStream() const { return *output_stream_; }
|
|
std::ostream& GetErrorStream() const { return *error_stream_; }
|
|
virtual ~BenchmarkReporter();
|
|
static void PrintBasicContext(std::ostream* out, Context const& context);
|
|
|
|
private:
|
|
std::ostream* output_stream_;
|
|
std::ostream* error_stream_;
|
|
};
|
|
|
|
class BENCHMARK_EXPORT ConsoleReporter : public BenchmarkReporter {
|
|
public:
|
|
enum OutputOptions {
|
|
OO_None = 0,
|
|
OO_Color = 1,
|
|
OO_Tabular = 2,
|
|
OO_ColorTabular = OO_Color | OO_Tabular,
|
|
OO_Defaults = OO_ColorTabular
|
|
};
|
|
explicit ConsoleReporter(OutputOptions opts_ = OO_Defaults)
|
|
: output_options_(opts_), name_field_width_(0), printed_header_(false) {}
|
|
|
|
bool ReportContext(const Context& context) override;
|
|
void ReportRuns(const std::vector<Run>& reports) override;
|
|
|
|
protected:
|
|
virtual void PrintRunData(const Run& result);
|
|
virtual void PrintHeader(const Run& run);
|
|
|
|
OutputOptions output_options_;
|
|
size_t name_field_width_;
|
|
UserCounters prev_counters_;
|
|
bool printed_header_;
|
|
};
|
|
|
|
class BENCHMARK_EXPORT JSONReporter : public BenchmarkReporter {
|
|
public:
|
|
JSONReporter() : first_report_(true) {}
|
|
bool ReportContext(const Context& context) override;
|
|
void ReportRuns(const std::vector<Run>& reports) override;
|
|
void Finalize() override;
|
|
|
|
private:
|
|
void PrintRunData(const Run& run);
|
|
bool first_report_;
|
|
};
|
|
|
|
class BENCHMARK_EXPORT BENCHMARK_DEPRECATED_MSG(
|
|
"The CSV Reporter will be removed in a future release") CSVReporter
|
|
: public BenchmarkReporter {
|
|
public:
|
|
CSVReporter() : printed_header_(false) {}
|
|
bool ReportContext(const Context& context) override;
|
|
void ReportRuns(const std::vector<Run>& reports) override;
|
|
|
|
private:
|
|
void PrintRunData(const Run& run);
|
|
bool printed_header_;
|
|
std::set<std::string> user_counter_names_;
|
|
};
|
|
|
|
inline const char* GetTimeUnitString(TimeUnit unit) {
|
|
switch (unit) {
|
|
case kSecond:
|
|
return "s";
|
|
case kMillisecond:
|
|
return "ms";
|
|
case kMicrosecond:
|
|
return "us";
|
|
case kNanosecond:
|
|
return "ns";
|
|
}
|
|
BENCHMARK_UNREACHABLE();
|
|
}
|
|
|
|
inline double GetTimeUnitMultiplier(TimeUnit unit) {
|
|
switch (unit) {
|
|
case kSecond:
|
|
return 1;
|
|
case kMillisecond:
|
|
return 1e3;
|
|
case kMicrosecond:
|
|
return 1e6;
|
|
case kNanosecond:
|
|
return 1e9;
|
|
}
|
|
BENCHMARK_UNREACHABLE();
|
|
}
|
|
|
|
} // namespace benchmark
|
|
|
|
#if defined(_MSC_VER)
|
|
#pragma warning(pop)
|
|
#endif
|
|
|
|
#endif // BENCHMARK_REPORTER_H_
|