From 7f992a553df82688e68b72228f5fbb533b04b750 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Thu, 23 May 2024 10:08:54 -0700 Subject: [PATCH 01/22] Improve compatibility with Hexagon hardware (#1785) The customization done via BENCHMARK_OS_QURT works just fine with the Hexagon simulator, but on at least some Hexagon hardware, both `qurt_timer_get_ticks()` and `std::chrono::now()` are broken and always return 0. This fixes the former by using the better-supported (and essentially identical `qurt_sysclock_get_hw_ticks()` call, and the latter by reading a 19.2MHz hardware counter (per suggestion from Qualcomm). Local testing seems to indicate these changes are just as robust under the simulator as before. --- src/timers.cc | 12 ++++++++++-- src/timers.h | 29 ++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/timers.cc b/src/timers.cc index d0821f3166..7ba540b88b 100644 --- a/src/timers.cc +++ b/src/timers.cc @@ -126,8 +126,12 @@ double ProcessCPUUsage() { return MakeTime(kernel_time, user_time); DiagnoseAndExit("GetProccessTimes() failed"); #elif defined(BENCHMARK_OS_QURT) + // Note that qurt_timer_get_ticks() is no longer documented as of SDK 5.3.0, + // and doesn't appear to work on at least some devices (eg Samsung S22), + // so let's use the actually-documented and apparently-equivalent + // qurt_sysclock_get_hw_ticks() call instead. return static_cast( - qurt_timer_timetick_to_us(qurt_timer_get_ticks())) * + qurt_timer_timetick_to_us(qurt_sysclock_get_hw_ticks())) * 1.0e-6; #elif defined(BENCHMARK_OS_EMSCRIPTEN) // clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ...) returns 0 on Emscripten. @@ -160,8 +164,12 @@ double ThreadCPUUsage() { &user_time); return MakeTime(kernel_time, user_time); #elif defined(BENCHMARK_OS_QURT) + // Note that qurt_timer_get_ticks() is no longer documented as of SDK 5.3.0, + // and doesn't appear to work on at least some devices (eg Samsung S22), + // so let's use the actually-documented and apparently-equivalent + // qurt_sysclock_get_hw_ticks() call instead. return static_cast( - qurt_timer_timetick_to_us(qurt_timer_get_ticks())) * + qurt_timer_timetick_to_us(qurt_sysclock_get_hw_ticks())) * 1.0e-6; #elif defined(BENCHMARK_OS_MACOSX) // FIXME We want to use clock_gettime, but its not available in MacOS 10.11. diff --git a/src/timers.h b/src/timers.h index 65606ccd93..690086b36c 100644 --- a/src/timers.h +++ b/src/timers.h @@ -15,6 +15,29 @@ double ChildrenCPUUsage(); // Return the CPU usage of the current thread double ThreadCPUUsage(); +#if defined(BENCHMARK_OS_QURT) + +// std::chrono::now() can return 0 on some Hexagon devices; +// this reads the value of a 56-bit, 19.2MHz hardware counter +// and converts it to seconds. Unlike std::chrono, this doesn't +// return an absolute time, but since ChronoClockNow() is only used +// to compute elapsed time, this shouldn't matter. +struct QuRTClock { + typedef uint64_t rep; + typedef std::ratio<1, 19200000> period; + typedef std::chrono::duration duration; + typedef std::chrono::time_point time_point; + static const bool is_steady = false; + + static time_point now() { + unsigned long long count; + asm volatile(" %0 = c31:30 " : "=r"(count)); + return time_point(static_cast(count)); + } +}; + +#else + #if defined(HAVE_STEADY_CLOCK) template struct ChooseSteadyClock { @@ -25,10 +48,14 @@ template <> struct ChooseSteadyClock { typedef std::chrono::steady_clock type; }; +#endif // HAVE_STEADY_CLOCK + #endif struct ChooseClockType { -#if defined(HAVE_STEADY_CLOCK) +#if defined(BENCHMARK_OS_QURT) + typedef QuRTClock type; +#elif defined(HAVE_STEADY_CLOCK) typedef ChooseSteadyClock<>::type type; #else typedef std::chrono::high_resolution_clock type; From 144d23cf5fa0b1b9dd138bc56601920d83e350c7 Mon Sep 17 00:00:00 2001 From: Nicholas Junge Date: Fri, 24 May 2024 10:51:41 +0200 Subject: [PATCH 02/22] hotfix: Correct pypi-publishing action tag to v1.8.14 (#1791) Also bump pre-commit dependencies via `pre-commit autoupdate`. --- .github/workflows/wheels.yml | 2 +- .pre-commit-config.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 8b772cd8b9..591d709fba 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -87,4 +87,4 @@ jobs: - uses: actions/download-artifact@v4 with: path: dist - - uses: pypa/gh-action-pypi-publish@v1 + - uses: pypa/gh-action-pypi-publish@v1.8.14 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93455ab60d..a019caf416 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,13 +5,13 @@ repos: - id: buildifier - id: buildifier-lint - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.8.0 + rev: v1.10.0 hooks: - id: mypy types_or: [ python, pyi ] args: [ "--ignore-missing-imports", "--scripts-are-modules" ] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.1 + rev: v0.4.5 hooks: - id: ruff args: [ --fix, --exit-non-zero-on-fix ] From d77b69271091c35b1da5d47894d924832f8cfc37 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Tue, 28 May 2024 13:24:21 +0300 Subject: [PATCH 03/22] CMake: unbreak version handling for tarballs (#1793) #1742 changed the placeholder version from `0.0.0` to `v0.0.0`, but this line which was further dealing with it, was not updated. Fixes https://github.com/google/benchmark/issues/1792 Co-authored-by: dominic <510002+dmah42@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71396edacb..942ce98c58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,7 @@ get_git_version(GIT_VERSION) # If no git version can be determined, use the version # from the project() command -if ("${GIT_VERSION}" STREQUAL "0.0.0") +if ("${GIT_VERSION}" STREQUAL "v0.0.0") set(VERSION "v${benchmark_VERSION}") else() set(VERSION "${GIT_VERSION}") From 7f0e99af540a333108b92d792923ec7fc9e9fad9 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 28 May 2024 20:14:54 -0700 Subject: [PATCH 04/22] cycleclock: Fix type conversion to match function return type (#1794) fixes build with clang19 src/cycleclock.h:208:52: error: implicit conversion changes signedness: 'uint64_t' (aka 'unsigned long long') to 'int64_t' (aka 'long long') [-Werror,-Wsign-conversion] 208 | return (static_cast(cycles_hi1) << 32) | cycles_lo; | ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~ 1 error generated. --- src/cycleclock.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cycleclock.h b/src/cycleclock.h index a25843760b..c657414e56 100644 --- a/src/cycleclock.h +++ b/src/cycleclock.h @@ -205,7 +205,8 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { "sub %0, zero, %0\n" "and %1, %1, %0\n" : "=r"(cycles_hi0), "=r"(cycles_lo), "=r"(cycles_hi1)); - return (static_cast(cycles_hi1) << 32) | cycles_lo; + return static_cast((static_cast(cycles_hi1) << 32) | + cycles_lo); #else uint64_t cycles; asm volatile("rdtime %0" : "=r"(cycles)); From 10199fb48ec4fab83c93ef59c3156ef44584450a Mon Sep 17 00:00:00 2001 From: dominic <510002+dmah42@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:22:45 +0100 Subject: [PATCH 05/22] bump standard to C++14 (#1799) * update requirements to point to our dependencies doc * bump standard to c++14 --- BUILD.bazel | 2 +- CMakeLists.txt | 6 +----- README.md | 8 +++----- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 15d836998c..f7a1162baa 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -3,7 +3,7 @@ licenses(["notice"]) COPTS = [ "-pedantic", "-pedantic-errors", - "-std=c++11", + "-std=c++14", "-Wall", "-Wconversion", "-Wextra", diff --git a/CMakeLists.txt b/CMakeLists.txt index 942ce98c58..77eb30a3ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,11 +138,7 @@ if (BENCHMARK_BUILD_32_BITS) add_required_cxx_compiler_flag(-m32) endif() -if (MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") - set(BENCHMARK_CXX_STANDARD 14) -else() - set(BENCHMARK_CXX_STANDARD 11) -endif() +set(BENCHMARK_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD ${BENCHMARK_CXX_STANDARD}) set(CMAKE_CXX_STANDARD_REQUIRED YES) diff --git a/README.md b/README.md index a5e5d392d8..0b2a0ab63f 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,10 @@ IRC channels: The library can be used with C++03. However, it requires C++11 to build, including compiler and standard library support. -The following minimum versions are required to build the library: +_See [dependencies.md](docs/dependencies.md) for more details regarding supported +compilers and standards._ -* GCC 4.8 -* Clang 3.4 -* Visual Studio 14 2015 -* Intel 2015 Update 1 +If you have need for a particular compiler to be supported, patches are very welcome. See [Platform-Specific Build Instructions](docs/platform_specific_build_instructions.md). From 2fa4b26e5825d0b17577ae038c3b75e2d6b5418b Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Mon, 10 Jun 2024 12:08:49 +0200 Subject: [PATCH 06/22] Bump minimum required C++ version from C++11 to C++14 (#1800) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b2a0ab63f..8e5428f995 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ IRC channels: ## Requirements -The library can be used with C++03. However, it requires C++11 to build, +The library can be used with C++03. However, it requires C++14 to build, including compiler and standard library support. _See [dependencies.md](docs/dependencies.md) for more details regarding supported From 8e1823d6f59c1d0fdc084fd903c989e6816ea097 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 11 Jun 2024 05:37:35 -0700 Subject: [PATCH 07/22] cycleclock: Fix type conversion to match function return type on riscv64 (#1802) Fixes builds with clang src/cycleclock.h:213:10: error: implicit conversion changes signedness: 'uint64_t' (aka 'unsigned long') to 'int64_t' (aka 'long') [-Werror,-Wsign-conversion] 213 | return cycles; | ~~~~~~ ^~~~~~ 1 error generated. --- src/cycleclock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cycleclock.h b/src/cycleclock.h index c657414e56..bd62f5d7e7 100644 --- a/src/cycleclock.h +++ b/src/cycleclock.h @@ -210,7 +210,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { #else uint64_t cycles; asm volatile("rdtime %0" : "=r"(cycles)); - return cycles; + return static_cast(cycles); #endif #elif defined(__e2k__) || defined(__elbrus__) struct timeval tv; From 447752540c71f34d5d71046e08192db181e9b02b Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 17 Jun 2024 01:38:32 -0700 Subject: [PATCH 08/22] [bazel] Use `includes` instead of `strip_include_prefix` (#1803) When using `includes`, consumers will apply the headers using `-isystem`, instead of `-I`. This will allow diagnostics of consumers to not apply to `benchmark`. More info: https://bazel.build/reference/be/c-cpp#cc_library.includes https://bazel.build/reference/be/c-cpp#cc_library.strip_include_prefix gtest uses `includes` as well: https://github.com/google/googletest/blob/1d17ea141d2c11b8917d2c7d029f1c4e2b9769b2/BUILD.bazel#L120 --- BUILD.bazel | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index f7a1162baa..094ed62437 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -73,6 +73,7 @@ cc_library( ":perfcounters": ["HAVE_LIBPFM"], "//conditions:default": [], }), + includes = ["include"], linkopts = select({ ":windows": ["-DEFAULTLIB:shlwapi.lib"], "//conditions:default": ["-pthread"], @@ -87,7 +88,6 @@ cc_library( "_LARGEFILE64_SOURCE", "_LARGEFILE_SOURCE", ], - strip_include_prefix = "include", visibility = ["//visibility:public"], deps = select({ ":perfcounters": ["@libpfm"], @@ -102,7 +102,7 @@ cc_library( "include/benchmark/benchmark.h", "include/benchmark/export.h", ], - strip_include_prefix = "include", + includes = ["include"], visibility = ["//visibility:public"], deps = [":benchmark"], ) From c2146397ac69e6589a50f6b4fc6a7355669caed5 Mon Sep 17 00:00:00 2001 From: Stephen Nicholas Swatman Date: Wed, 19 Jun 2024 20:03:42 +0200 Subject: [PATCH 09/22] Find libpfm dependency in installed CMake configs (#1806) Currently, Google Benchmark can be built and installed with support for libpfm, but this can cause a problem if that installation is later called upon by another CMake project. Indeed, while the installed CMake configuration script correctly identifies that it needs to link against libpfm, it doesn't try to find libpfm, meaning that the target will be unavailable. This commit fixes this potential configuration-time error by ensuring that an installation of Google Benchmark will correctly try to find the libpfm dependency when it is used elsewhere. --- cmake/Config.cmake.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in index 2e15f0cf82..3659cfa2a6 100644 --- a/cmake/Config.cmake.in +++ b/cmake/Config.cmake.in @@ -4,4 +4,8 @@ include (CMakeFindDependencyMacro) find_dependency (Threads) +if (@BENCHMARK_ENABLE_LIBPFM@) + find_dependency (PFM) +endif() + include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") From 71f4218c1abf471eed27ccfbf98055a90ace39f6 Mon Sep 17 00:00:00 2001 From: Chris Cotter Date: Wed, 3 Jul 2024 14:16:43 -0400 Subject: [PATCH 10/22] Add -lkstat to the .pc for Solaris (#1801) * Add -lkstat to the .pc for Solaris This fixes linking for projects that rely on pkg-config to generate the link line on Solaris. Test plan: Built the project locally on Solaris and verified -kstat appears in the .pc file ``` $ cat lib/pkgconfig/benchmark.pc | grep Libs.private Libs.private: -lpthread -lkstat ``` * Use BENCHMARK_PRIVATE_LINK_LIBRARIES --- cmake/benchmark.pc.in | 2 +- src/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/benchmark.pc.in b/cmake/benchmark.pc.in index 9dae881c79..043f2fc759 100644 --- a/cmake/benchmark.pc.in +++ b/cmake/benchmark.pc.in @@ -8,5 +8,5 @@ Description: Google microbenchmark framework Version: @VERSION@ Libs: -L${libdir} -lbenchmark -Libs.private: -lpthread +Libs.private: -lpthread @BENCHMARK_PRIVATE_LINK_LIBRARIES@ Cflags: -I${includedir} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5551099b2a..d17964f9ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,6 +64,7 @@ endif() # We need extra libraries on Solaris if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") target_link_libraries(benchmark PRIVATE kstat) + set(BENCHMARK_PRIVATE_LINK_LIBRARIES -lkstat) endif() if (NOT BUILD_SHARED_LIBS) From 38df9daf489f7e359bbe6709099f0102398261d6 Mon Sep 17 00:00:00 2001 From: dominic <510002+dmah42@users.noreply.github.com> Date: Fri, 12 Jul 2024 10:28:16 +0100 Subject: [PATCH 11/22] add PERF_FORMAT_TOTAL_TIME_{ENABLED,RUNNING} to support multiplexing (#1814) --- src/perf_counters.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/perf_counters.cc b/src/perf_counters.cc index 2eb97eb46a..e2758afb95 100644 --- a/src/perf_counters.cc +++ b/src/perf_counters.cc @@ -157,7 +157,8 @@ PerfCounters PerfCounters::Create( attr.exclude_hv = true; // Read all counters in a group in one read. - attr.read_format = PERF_FORMAT_GROUP; + attr.read_format = PERF_FORMAT_GROUP | PERF_FORMAT_TOTAL_TIME_ENABLED | + PERF_FORMAT_TOTAL_TIME_RUNNING; int id = -1; while (id < 0) { From d2cd246e19bdf4de9fe357daec52cbe38303d9d6 Mon Sep 17 00:00:00 2001 From: "Jiawen (Kevin) Chen" Date: Tue, 16 Jul 2024 01:51:56 -0700 Subject: [PATCH 12/22] Clarify the difference between `BENCHMARK_TEMPLATE_F` and `BENCHMARK_TEMPLATE_DEFINE_F` + `BENCHMARK_REGISTER_F` (#1815) * Clarify BENCHMARK_REGISTER_F Add comments highlighting the difference between `BENCHMARK_TEMPLATE_F` and `BENCHMARK_TEMPLATE_DEFINE_F`, mirroring those of `BENCHMARK_F ` and `BENCHMARK_DEFINE_F`. * More informative comments. * Update user_guide.md --- docs/user_guide.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/user_guide.md b/docs/user_guide.md index d22a906909..d87ccc4026 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -624,20 +624,22 @@ public: } }; +// Defines and registers `FooTest` using the class `MyFixture`. BENCHMARK_F(MyFixture, FooTest)(benchmark::State& st) { for (auto _ : st) { ... } } +// Only defines `BarTest` using the class `MyFixture`. BENCHMARK_DEFINE_F(MyFixture, BarTest)(benchmark::State& st) { for (auto _ : st) { ... } } -/* BarTest is NOT registered */ +// `BarTest` is NOT registered. BENCHMARK_REGISTER_F(MyFixture, BarTest)->Threads(2); -/* BarTest is now registered */ +// `BarTest` is now registered. ``` ### Templated Fixtures @@ -653,19 +655,22 @@ For example: template class MyFixture : public benchmark::Fixture {}; +// Defines and registers `IntTest` using the class template `MyFixture`. BENCHMARK_TEMPLATE_F(MyFixture, IntTest, int)(benchmark::State& st) { for (auto _ : st) { ... } } +// Only defines `DoubleTest` using the class template `MyFixture`. BENCHMARK_TEMPLATE_DEFINE_F(MyFixture, DoubleTest, double)(benchmark::State& st) { for (auto _ : st) { ... } } - +// `DoubleTest` is NOT registered. BENCHMARK_REGISTER_F(MyFixture, DoubleTest)->Threads(2); +// `DoubleTest` is now registered. ``` @@ -1012,11 +1017,11 @@ in any way. `` may even be removed entirely when the result is already known. For example: ```c++ - /* Example 1: `` is removed entirely. */ + // Example 1: `` is removed entirely. int foo(int x) { return x + 42; } while (...) DoNotOptimize(foo(0)); // Optimized to DoNotOptimize(42); - /* Example 2: Result of '' is only reused */ + // Example 2: Result of '' is only reused. int bar(int) __attribute__((const)); while (...) DoNotOptimize(bar(0)); // Optimized to: // int __result__ = bar(0); From 7c8ed6b082aa3c7a3402f18e50da4480421d08fd Mon Sep 17 00:00:00 2001 From: xdje42 Date: Tue, 16 Jul 2024 01:56:40 -0700 Subject: [PATCH 13/22] [FR] Add API to provide custom profilers #1807 (#1809) This API is akin to the MemoryManager API and lets tools provide their own profiler which is wrapped in the same way MemoryManager is wrapped. Namely, the profiler provides Start/Stop methods that are called at the start/end of running the benchmark in a separate pass. Co-authored-by: dominic <510002+dmah42@users.noreply.github.com> --- CONTRIBUTORS | 1 + docs/user_guide.md | 15 +++++++++ include/benchmark/benchmark.h | 20 ++++++++++++ src/benchmark.cc | 4 +++ src/benchmark_runner.cc | 59 +++++++++++++++++++++++++---------- src/benchmark_runner.h | 5 +++ test/CMakeLists.txt | 3 ++ test/profiler_manager_test.cc | 43 +++++++++++++++++++++++++ 8 files changed, 134 insertions(+), 16 deletions(-) create mode 100644 test/profiler_manager_test.cc diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 9ca2caa3ee..54aba7b56d 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -42,6 +42,7 @@ Dominic Hamon Dominik Czarnota Dominik Korman Donald Aingworth +Doug Evans Eric Backus Eric Fiselier Eugene Zhuk diff --git a/docs/user_guide.md b/docs/user_guide.md index d87ccc4026..e38262099d 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -1139,6 +1139,21 @@ a report on the number of allocations, bytes used, etc. This data will then be reported alongside other performance data, currently only when using JSON output. + + +## Profiling + +It's often useful to also profile benchmarks in particular ways, in addition to +CPU performance. For this reason, benchmark offers the `RegisterProfilerManager` +method that allows a custom `ProfilerManager` to be injected. + +If set, the `ProfilerManager::AfterSetupStart` and +`ProfilerManager::BeforeTeardownStop` methods will be called at the start and +end of a separate benchmark run to allow user code to collect and report +user-provided profile metrics. + +Output collected from this profiling run must be reported separately. + ## Using RegisterBenchmark(name, fn, args...) diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index 08cfe29da3..7dd72e27bc 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -416,6 +416,26 @@ class MemoryManager { BENCHMARK_EXPORT void RegisterMemoryManager(MemoryManager* memory_manager); +// If a ProfilerManager is registered (via RegisterProfilerManager()), the +// benchmark will be run an additional time under the profiler to collect and +// report profile metrics for the run of the benchmark. +class ProfilerManager { + public: + virtual ~ProfilerManager() {} + + // This is called after `Setup()` code and right before the benchmark is run. + virtual void AfterSetupStart() = 0; + + // This is called before `Teardown()` code and right after the benchmark + // completes. + virtual void BeforeTeardownStop() = 0; +}; + +// Register a ProfilerManager instance that will be used to collect and report +// profile measurements for benchmark runs. +BENCHMARK_EXPORT +void RegisterProfilerManager(ProfilerManager* profiler_manager); + // Add a key-value pair to output as part of the context stanza in the report. BENCHMARK_EXPORT void AddCustomContext(const std::string& key, const std::string& value); diff --git a/src/benchmark.cc b/src/benchmark.cc index 337bb3faa7..374c5141c9 100644 --- a/src/benchmark.cc +++ b/src/benchmark.cc @@ -656,6 +656,10 @@ void RegisterMemoryManager(MemoryManager* manager) { internal::memory_manager = manager; } +void RegisterProfilerManager(ProfilerManager* manager) { + internal::profiler_manager = manager; +} + void AddCustomContext(const std::string& key, const std::string& value) { if (internal::global_context == nullptr) { internal::global_context = new std::map(); diff --git a/src/benchmark_runner.cc b/src/benchmark_runner.cc index a74bdadd3e..3a8c3076a4 100644 --- a/src/benchmark_runner.cc +++ b/src/benchmark_runner.cc @@ -62,6 +62,8 @@ namespace internal { MemoryManager* memory_manager = nullptr; +ProfilerManager* profiler_manager = nullptr; + namespace { static constexpr IterationCount kMaxIterations = 1000000000000; @@ -401,6 +403,41 @@ void BenchmarkRunner::RunWarmUp() { } } +MemoryManager::Result* BenchmarkRunner::RunMemoryManager( + IterationCount memory_iterations) { + // TODO(vyng): Consider making BenchmarkReporter::Run::memory_result an + // optional so we don't have to own the Result here. + // Can't do it now due to cxx03. + memory_results.push_back(MemoryManager::Result()); + MemoryManager::Result* memory_result = &memory_results.back(); + memory_manager->Start(); + std::unique_ptr manager; + manager.reset(new internal::ThreadManager(1)); + b.Setup(); + RunInThread(&b, memory_iterations, 0, manager.get(), + perf_counters_measurement_ptr); + manager->WaitForAllThreads(); + manager.reset(); + b.Teardown(); + memory_manager->Stop(*memory_result); + return memory_result; +} + +void BenchmarkRunner::RunProfilerManager() { + // TODO: Provide a way to specify the number of iterations. + IterationCount profile_iterations = 1; + std::unique_ptr manager; + manager.reset(new internal::ThreadManager(1)); + b.Setup(); + profiler_manager->AfterSetupStart(); + RunInThread(&b, profile_iterations, 0, manager.get(), + /*perf_counters_measurement_ptr=*/nullptr); + manager->WaitForAllThreads(); + profiler_manager->BeforeTeardownStop(); + manager.reset(); + b.Teardown(); +} + void BenchmarkRunner::DoOneRepetition() { assert(HasRepeatsRemaining() && "Already done all repetitions?"); @@ -445,28 +482,18 @@ void BenchmarkRunner::DoOneRepetition() { "then we should have accepted the current iteration run."); } - // Oh, one last thing, we need to also produce the 'memory measurements'.. + // Produce memory measurements if requested. MemoryManager::Result* memory_result = nullptr; IterationCount memory_iterations = 0; if (memory_manager != nullptr) { - // TODO(vyng): Consider making BenchmarkReporter::Run::memory_result an - // optional so we don't have to own the Result here. - // Can't do it now due to cxx03. - memory_results.push_back(MemoryManager::Result()); - memory_result = &memory_results.back(); // Only run a few iterations to reduce the impact of one-time // allocations in benchmarks that are not properly managed. memory_iterations = std::min(16, iters); - memory_manager->Start(); - std::unique_ptr manager; - manager.reset(new internal::ThreadManager(1)); - b.Setup(); - RunInThread(&b, memory_iterations, 0, manager.get(), - perf_counters_measurement_ptr); - manager->WaitForAllThreads(); - manager.reset(); - b.Teardown(); - memory_manager->Stop(*memory_result); + memory_result = RunMemoryManager(memory_iterations); + } + + if (profiler_manager != nullptr) { + RunProfilerManager(); } // Ok, now actually report. diff --git a/src/benchmark_runner.h b/src/benchmark_runner.h index db2fa04396..cd34d2d5bb 100644 --- a/src/benchmark_runner.h +++ b/src/benchmark_runner.h @@ -35,6 +35,7 @@ BM_DECLARE_string(benchmark_perf_counters); namespace internal { extern MemoryManager* memory_manager; +extern ProfilerManager* profiler_manager; struct RunResults { std::vector non_aggregates; @@ -113,6 +114,10 @@ class BenchmarkRunner { }; IterationResults DoNIterations(); + MemoryManager::Result* RunMemoryManager(IterationCount memory_iterations); + + void RunProfilerManager(); + IterationCount PredictNumItersNeeded(const IterationResults& i) const; bool ShouldReportIterationResults(const IterationResults& i) const; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1de175f98d..815b581889 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -192,6 +192,9 @@ benchmark_add_test(NAME user_counters_thousands_test COMMAND user_counters_thous compile_output_test(memory_manager_test) benchmark_add_test(NAME memory_manager_test COMMAND memory_manager_test --benchmark_min_time=0.01s) +compile_output_test(profiler_manager_test) +benchmark_add_test(NAME profiler_manager_test COMMAND profiler_manager_test --benchmark_min_time=0.01s) + # MSVC does not allow to set the language standard to C++98/03. if(NOT (MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")) compile_benchmark_test(cxx03_test) diff --git a/test/profiler_manager_test.cc b/test/profiler_manager_test.cc new file mode 100644 index 0000000000..1b3e36c37f --- /dev/null +++ b/test/profiler_manager_test.cc @@ -0,0 +1,43 @@ +// FIXME: WIP + +#include + +#include "benchmark/benchmark.h" +#include "output_test.h" + +class TestProfilerManager : public benchmark::ProfilerManager { + void AfterSetupStart() override {} + void BeforeTeardownStop() override {} +}; + +void BM_empty(benchmark::State& state) { + for (auto _ : state) { + auto iterations = state.iterations(); + benchmark::DoNotOptimize(iterations); + } +} +BENCHMARK(BM_empty); + +ADD_CASES(TC_ConsoleOut, {{"^BM_empty %console_report$"}}); +ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_empty\",$"}, + {"\"family_index\": 0,$", MR_Next}, + {"\"per_family_instance_index\": 0,$", MR_Next}, + {"\"run_name\": \"BM_empty\",$", MR_Next}, + {"\"run_type\": \"iteration\",$", MR_Next}, + {"\"repetitions\": 1,$", MR_Next}, + {"\"repetition_index\": 0,$", MR_Next}, + {"\"threads\": 1,$", MR_Next}, + {"\"iterations\": %int,$", MR_Next}, + {"\"real_time\": %float,$", MR_Next}, + {"\"cpu_time\": %float,$", MR_Next}, + {"\"time_unit\": \"ns\"$", MR_Next}, + {"}", MR_Next}}); +ADD_CASES(TC_CSVOut, {{"^\"BM_empty\",%csv_report$"}}); + +int main(int argc, char* argv[]) { + std::unique_ptr pm(new TestProfilerManager()); + + benchmark::RegisterProfilerManager(pm.get()); + RunOutputTests(argc, argv); + benchmark::RegisterProfilerManager(nullptr); +} From 14ddd77a90152b190e5f428018245dca9d890761 Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Tue, 16 Jul 2024 17:39:51 +0100 Subject: [PATCH 14/22] remove old travis config --- .travis.yml | 208 ---------------------------------------------------- 1 file changed, 208 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8cfed3d10d..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,208 +0,0 @@ -sudo: required -dist: trusty -language: cpp - -matrix: - include: - - compiler: gcc - addons: - apt: - packages: - - lcov - env: COMPILER=g++ C_COMPILER=gcc BUILD_TYPE=Coverage - - compiler: gcc - addons: - apt: - packages: - - g++-multilib - - libc6:i386 - env: - - COMPILER=g++ - - C_COMPILER=gcc - - BUILD_TYPE=Debug - - BUILD_32_BITS=ON - - EXTRA_FLAGS="-m32" - - compiler: gcc - addons: - apt: - packages: - - g++-multilib - - libc6:i386 - env: - - COMPILER=g++ - - C_COMPILER=gcc - - BUILD_TYPE=Release - - BUILD_32_BITS=ON - - EXTRA_FLAGS="-m32" - - compiler: gcc - env: - - INSTALL_GCC6_FROM_PPA=1 - - COMPILER=g++-6 C_COMPILER=gcc-6 BUILD_TYPE=Debug - - ENABLE_SANITIZER=1 - - EXTRA_FLAGS="-fno-omit-frame-pointer -g -O2 -fsanitize=undefined,address -fuse-ld=gold" - # Clang w/ libc++ - - compiler: clang - dist: xenial - addons: - apt: - packages: - clang-3.8 - env: - - INSTALL_GCC6_FROM_PPA=1 - - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug - - LIBCXX_BUILD=1 - - EXTRA_CXX_FLAGS="-stdlib=libc++" - - compiler: clang - dist: xenial - addons: - apt: - packages: - clang-3.8 - env: - - INSTALL_GCC6_FROM_PPA=1 - - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Release - - LIBCXX_BUILD=1 - - EXTRA_CXX_FLAGS="-stdlib=libc++" - # Clang w/ 32bit libc++ - - compiler: clang - dist: xenial - addons: - apt: - packages: - - clang-3.8 - - g++-multilib - - libc6:i386 - env: - - INSTALL_GCC6_FROM_PPA=1 - - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug - - LIBCXX_BUILD=1 - - BUILD_32_BITS=ON - - EXTRA_FLAGS="-m32" - - EXTRA_CXX_FLAGS="-stdlib=libc++" - # Clang w/ 32bit libc++ - - compiler: clang - dist: xenial - addons: - apt: - packages: - - clang-3.8 - - g++-multilib - - libc6:i386 - env: - - INSTALL_GCC6_FROM_PPA=1 - - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Release - - LIBCXX_BUILD=1 - - BUILD_32_BITS=ON - - EXTRA_FLAGS="-m32" - - EXTRA_CXX_FLAGS="-stdlib=libc++" - # Clang w/ libc++, ASAN, UBSAN - - compiler: clang - dist: xenial - addons: - apt: - packages: - clang-3.8 - env: - - INSTALL_GCC6_FROM_PPA=1 - - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug - - LIBCXX_BUILD=1 LIBCXX_SANITIZER="Undefined;Address" - - ENABLE_SANITIZER=1 - - EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=undefined,address -fno-sanitize-recover=all" - - EXTRA_CXX_FLAGS="-stdlib=libc++" - - UBSAN_OPTIONS=print_stacktrace=1 - # Clang w/ libc++ and MSAN - - compiler: clang - dist: xenial - addons: - apt: - packages: - clang-3.8 - env: - - INSTALL_GCC6_FROM_PPA=1 - - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=Debug - - LIBCXX_BUILD=1 LIBCXX_SANITIZER=MemoryWithOrigins - - ENABLE_SANITIZER=1 - - EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=memory -fsanitize-memory-track-origins" - - EXTRA_CXX_FLAGS="-stdlib=libc++" - # Clang w/ libc++ and MSAN - - compiler: clang - dist: xenial - addons: - apt: - packages: - clang-3.8 - env: - - INSTALL_GCC6_FROM_PPA=1 - - COMPILER=clang++-3.8 C_COMPILER=clang-3.8 BUILD_TYPE=RelWithDebInfo - - LIBCXX_BUILD=1 LIBCXX_SANITIZER=Thread - - ENABLE_SANITIZER=1 - - EXTRA_FLAGS="-g -O2 -fno-omit-frame-pointer -fsanitize=thread -fno-sanitize-recover=all" - - EXTRA_CXX_FLAGS="-stdlib=libc++" - - os: osx - osx_image: xcode8.3 - compiler: clang - env: - - COMPILER=clang++ - - BUILD_TYPE=Release - - BUILD_32_BITS=ON - - EXTRA_FLAGS="-m32" - -before_script: - - if [ -n "${LIBCXX_BUILD}" ]; then - source .libcxx-setup.sh; - fi - - if [ -n "${ENABLE_SANITIZER}" ]; then - export EXTRA_OPTIONS="-DBENCHMARK_ENABLE_ASSEMBLY_TESTS=OFF"; - else - export EXTRA_OPTIONS=""; - fi - - mkdir -p build && cd build - -before_install: - - if [ -z "$BUILD_32_BITS" ]; then - export BUILD_32_BITS=OFF && echo disabling 32 bit build; - fi - - if [ -n "${INSTALL_GCC6_FROM_PPA}" ]; then - sudo add-apt-repository -y "ppa:ubuntu-toolchain-r/test"; - sudo apt-get update --option Acquire::Retries=100 --option Acquire::http::Timeout="60"; - fi - -install: - - if [ -n "${INSTALL_GCC6_FROM_PPA}" ]; then - travis_wait sudo -E apt-get -yq --no-install-suggests --no-install-recommends install g++-6; - fi - - if [ "${TRAVIS_OS_NAME}" == "linux" -a "${BUILD_32_BITS}" == "OFF" ]; then - travis_wait sudo -E apt-get -y --no-install-suggests --no-install-recommends install llvm-3.9-tools; - sudo cp /usr/lib/llvm-3.9/bin/FileCheck /usr/local/bin/; - fi - - if [ "${BUILD_TYPE}" == "Coverage" -a "${TRAVIS_OS_NAME}" == "linux" ]; then - PATH=~/.local/bin:${PATH}; - pip install --user --upgrade pip; - travis_wait pip install --user cpp-coveralls; - fi - - if [ "${C_COMPILER}" == "gcc-7" -a "${TRAVIS_OS_NAME}" == "osx" ]; then - rm -f /usr/local/include/c++; - brew update; - travis_wait brew install gcc@7; - fi - - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then - sudo apt-get update -qq; - sudo apt-get install -qq unzip cmake3; - wget https://github.com/bazelbuild/bazel/releases/download/3.2.0/bazel-3.2.0-installer-linux-x86_64.sh --output-document bazel-installer.sh; - travis_wait sudo bash bazel-installer.sh; - fi - - if [ "${TRAVIS_OS_NAME}" == "osx" ]; then - curl -L -o bazel-installer.sh https://github.com/bazelbuild/bazel/releases/download/3.2.0/bazel-3.2.0-installer-darwin-x86_64.sh; - travis_wait sudo bash bazel-installer.sh; - fi - -script: - - cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_C_FLAGS="${EXTRA_FLAGS}" -DCMAKE_CXX_FLAGS="${EXTRA_FLAGS} ${EXTRA_CXX_FLAGS}" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON -DBENCHMARK_BUILD_32_BITS=${BUILD_32_BITS} ${EXTRA_OPTIONS} .. - - make - - ctest -C ${BUILD_TYPE} --output-on-failure - - bazel test -c dbg --define google_benchmark.have_regex=posix --announce_rc --verbose_failures --test_output=errors --keep_going //test/... - -after_success: - - if [ "${BUILD_TYPE}" == "Coverage" -a "${TRAVIS_OS_NAME}" == "linux" ]; then - coveralls --include src --include include --gcov-options '\-lp' --root .. --build-root .; - fi From 65668db27365d29ca4890cb2102e81acb6585b43 Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Tue, 16 Jul 2024 17:45:30 +0100 Subject: [PATCH 15/22] revert perf counters change until we can do the full version --- src/perf_counters.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/perf_counters.cc b/src/perf_counters.cc index e2758afb95..8e5219bc88 100644 --- a/src/perf_counters.cc +++ b/src/perf_counters.cc @@ -157,8 +157,8 @@ PerfCounters PerfCounters::Create( attr.exclude_hv = true; // Read all counters in a group in one read. - attr.read_format = PERF_FORMAT_GROUP | PERF_FORMAT_TOTAL_TIME_ENABLED | - PERF_FORMAT_TOTAL_TIME_RUNNING; + attr.read_format = PERF_FORMAT_GROUP; //| PERF_FORMAT_TOTAL_TIME_ENABLED | + //PERF_FORMAT_TOTAL_TIME_RUNNING; int id = -1; while (id < 0) { From a73c039b1d7a389fb7f5b29ab5e966df4d128fdf Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Wed, 17 Jul 2024 13:18:38 +0100 Subject: [PATCH 16/22] roll back fatal error that breaks some platform (wasm) expectations --- src/sysinfo.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sysinfo.cc b/src/sysinfo.cc index 7261e2a96b..708a3e0088 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -508,7 +508,8 @@ int GetNumCPUsImpl() { int max_id = -1; std::ifstream f("/proc/cpuinfo"); if (!f.is_open()) { - PrintErrorAndDie("Failed to open /proc/cpuinfo"); + std::cerr << "Failed to open /proc/cpuinfo\n"; + return -1; } #if defined(__alpha__) const std::string Key = "cpus detected"; From 99410f400c064e071473ba64675fa6604f6941b1 Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Wed, 17 Jul 2024 13:25:16 +0100 Subject: [PATCH 17/22] clang-format fixes --- src/CMakeLists.txt | 2 +- src/perf_counters.cc | 4 ++-- src/sysinfo.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d17964f9ba..32126c0d24 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# Allow the source files to find headers in src/ +#Allow the source files to find headers in src / include(GNUInstallDirs) include_directories(${PROJECT_SOURCE_DIR}/src) diff --git a/src/perf_counters.cc b/src/perf_counters.cc index 8e5219bc88..fa1cbb0e8f 100644 --- a/src/perf_counters.cc +++ b/src/perf_counters.cc @@ -157,8 +157,8 @@ PerfCounters PerfCounters::Create( attr.exclude_hv = true; // Read all counters in a group in one read. - attr.read_format = PERF_FORMAT_GROUP; //| PERF_FORMAT_TOTAL_TIME_ENABLED | - //PERF_FORMAT_TOTAL_TIME_RUNNING; + attr.read_format = PERF_FORMAT_GROUP; //| PERF_FORMAT_TOTAL_TIME_ENABLED | + // PERF_FORMAT_TOTAL_TIME_RUNNING; int id = -1; while (id < 0) { diff --git a/src/sysinfo.cc b/src/sysinfo.cc index 708a3e0088..421a0bde38 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -120,7 +120,7 @@ struct ValueUnion { explicit ValueUnion(std::size_t buff_size) : size(sizeof(DataT) + buff_size), - buff(::new (std::malloc(size)) DataT(), &std::free) {} + buff(::new(std::malloc(size)) DataT(), &std::free) {} ValueUnion(ValueUnion&& other) = default; From 299a8b881df5fcd9e2130919c818bb15762b8d28 Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Wed, 17 Jul 2024 13:27:41 +0100 Subject: [PATCH 18/22] clang format header fixes --- include/benchmark/benchmark.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index 7dd72e27bc..dc87676832 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -674,7 +674,7 @@ class Counter { Counter(double v = 0., Flags f = kDefaults, OneK k = kIs1000) : value(v), flags(f), oneK(k) {} - BENCHMARK_ALWAYS_INLINE operator double const &() const { return value; } + BENCHMARK_ALWAYS_INLINE operator double const&() const { return value; } BENCHMARK_ALWAYS_INLINE operator double&() { return value; } }; From 44507bc91ff9a23ad8ad4120cfc6b0d9bd27e2ca Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Wed, 17 Jul 2024 16:39:15 +0100 Subject: [PATCH 19/22] another reversal of something that breaks on wasm --- src/sysinfo.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sysinfo.cc b/src/sysinfo.cc index 421a0bde38..4638641129 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -558,9 +558,8 @@ int GetNumCPUsImpl() { int GetNumCPUs() { const int num_cpus = GetNumCPUsImpl(); if (num_cpus < 1) { - PrintErrorAndDie( - "Unable to extract number of CPUs. If your platform uses " - "/proc/cpuinfo, custom support may need to be added."); + std::cerr << "Unable to extract number of CPUs. If your platform uses " + "/proc/cpuinfo, custom support may need to be added.\n"; } return num_cpus; } From 4b184d47a41ed13c6d985b5a7b06498aa5aebaf3 Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Wed, 17 Jul 2024 16:47:54 +0100 Subject: [PATCH 20/22] update actions/checkout to v4 --- .github/workflows/build-and-test-min-cmake.yml | 2 +- .github/workflows/build-and-test-perfcounters.yml | 2 +- .github/workflows/build-and-test.yml | 6 +++--- .github/workflows/clang-format-lint.yml | 2 +- .github/workflows/clang-tidy.yml | 2 +- .github/workflows/doxygen.yml | 2 +- .github/workflows/sanitizer.yml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-test-min-cmake.yml b/.github/workflows/build-and-test-min-cmake.yml index e3e321752d..b49800629b 100644 --- a/.github/workflows/build-and-test-min-cmake.yml +++ b/.github/workflows/build-and-test-min-cmake.yml @@ -16,7 +16,7 @@ jobs: os: [ubuntu-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: lukka/get-cmake@latest with: diff --git a/.github/workflows/build-and-test-perfcounters.yml b/.github/workflows/build-and-test-perfcounters.yml index 97e4d8ea63..319d42d87e 100644 --- a/.github/workflows/build-and-test-perfcounters.yml +++ b/.github/workflows/build-and-test-perfcounters.yml @@ -17,7 +17,7 @@ jobs: os: [ubuntu-22.04, ubuntu-20.04] build_type: ['Release', 'Debug'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install libpfm run: | diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 95e0482aea..d05300db06 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -23,7 +23,7 @@ jobs: lib: ['shared', 'static'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: lukka/get-cmake@latest @@ -87,7 +87,7 @@ jobs: generator: 'Visual Studio 17 2022' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: lukka/get-cmake@latest @@ -129,7 +129,7 @@ jobs: - static steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install Base Dependencies uses: msys2/setup-msys2@v2 diff --git a/.github/workflows/clang-format-lint.yml b/.github/workflows/clang-format-lint.yml index 328fe36cc7..c790a5a552 100644 --- a/.github/workflows/clang-format-lint.yml +++ b/.github/workflows/clang-format-lint.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: DoozyX/clang-format-lint-action@v0.13 with: source: './include/benchmark ./src ./test' diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 2eaab9c1e2..558375e3ae 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install clang-tidy run: sudo apt update && sudo apt -y install clang-tidy diff --git a/.github/workflows/doxygen.yml b/.github/workflows/doxygen.yml index da92c46a2d..40c1cb4ebc 100644 --- a/.github/workflows/doxygen.yml +++ b/.github/workflows/doxygen.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Fetching sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Installing build dependencies run: | diff --git a/.github/workflows/sanitizer.yml b/.github/workflows/sanitizer.yml index 86cccf4102..499215331a 100644 --- a/.github/workflows/sanitizer.yml +++ b/.github/workflows/sanitizer.yml @@ -18,7 +18,7 @@ jobs: sanitizer: ['asan', 'ubsan', 'tsan', 'msan'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: configure msan env if: matrix.sanitizer == 'msan' From ad2b1c9ed1ec3120fdf68ad9877ab20681ceb09d Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Wed, 17 Jul 2024 16:49:12 +0100 Subject: [PATCH 21/22] clang format yet again --- include/benchmark/benchmark.h | 2 +- src/sysinfo.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h index dc87676832..7dd72e27bc 100644 --- a/include/benchmark/benchmark.h +++ b/include/benchmark/benchmark.h @@ -674,7 +674,7 @@ class Counter { Counter(double v = 0., Flags f = kDefaults, OneK k = kIs1000) : value(v), flags(f), oneK(k) {} - BENCHMARK_ALWAYS_INLINE operator double const&() const { return value; } + BENCHMARK_ALWAYS_INLINE operator double const &() const { return value; } BENCHMARK_ALWAYS_INLINE operator double&() { return value; } }; diff --git a/src/sysinfo.cc b/src/sysinfo.cc index 4638641129..a153b20cf3 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -120,7 +120,7 @@ struct ValueUnion { explicit ValueUnion(std::size_t buff_size) : size(sizeof(DataT) + buff_size), - buff(::new(std::malloc(size)) DataT(), &std::free) {} + buff(::new (std::malloc(size)) DataT(), &std::free) {} ValueUnion(ValueUnion&& other) = default; From a6ad7fbbdc2e14fab82bb8a6d27760d700198cbf Mon Sep 17 00:00:00 2001 From: Dominic Hamon Date: Thu, 18 Jul 2024 11:13:04 +0100 Subject: [PATCH 22/22] preparing for v1.8.5 --- CMakeLists.txt | 2 +- MODULE.bazel | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77eb30a3ea..216c1c9212 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Require CMake 3.10. If available, use the policies up to CMake 3.22. cmake_minimum_required (VERSION 3.10...3.22) -project (benchmark VERSION 1.8.4 LANGUAGES CXX) +project (benchmark VERSION 1.8.5 LANGUAGES CXX) option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON) option(BENCHMARK_ENABLE_EXCEPTIONS "Enable the use of exceptions in the benchmark library." ON) diff --git a/MODULE.bazel b/MODULE.bazel index 0624a34f01..8b98a7a027 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,6 +1,6 @@ module( name = "google_benchmark", - version = "1.8.4", + version = "1.8.5", ) bazel_dep(name = "bazel_skylib", version = "1.5.0")