ronantakizawa/codereview-bench huggingface dataset:
Repository: google/benchmark
File: src/timers.cc (C++)

Code before:
#include "internal_macros.h"

#ifdef BENCHMARK_OS_WINDOWS
#include <shlwapi.h>
#undef StrCat  // Don't let StrCat in string_util.h be renamed to lstrcatA
#include <versionhelpers.h>
#include <windows.h>
#else
#include <fcntl.h>
#if !defined(BENCHMARK_OS_FUCHSIA) && !defined(BENCHMARK_OS_QURT)
#include <sys/resource.h>
#endif
#include <sys/time.h>
#include <sys/types.h>  // this header must be included before 'sys/sysctl.h' to avoid compilation error on FreeBSD
#include <unistd.h>
#if defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_DRAGONFLY || \
    defined BENCHMARK_OS_MACOSX
#include <sys/sysctl.h>
#endif
#if defined(BENCHMARK_OS_MACOSX)
#include <mach/mach_init.h>
#include <mach/mach_port.h>
#include <mach/thread_act.h>
#endif
#if defined(BENCHMARK_OS_QURT)
#include <qurt/qurt.h>
#endif
#endif

#ifdef BENCHMARK_OS_EMSCRIPTEN
#include <emscripten.h>
#endif

#include <cerrno>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <limits>
#include <mutex>

#include "check.h"
#include "log.h"
#include "sleep.h"
#include "string_util.h"

namespace benchmark {

// Suppress unused warnings on helper functions.

Review comment (suggestion):
is there a difference between `<qurt.h>` and `<qurt/qurt.h>`? you use both in this change.

Code after:
#include "internal_macros.h"

#ifdef BENCHMARK_OS_WINDOWS
#include <shlwapi.h>
#undef StrCat  // Don't let StrCat in string_util.h be renamed to lstrcatA
#include <versionhelpers.h>
#include <windows.h>
#else
#include <fcntl.h>
#if !defined(BENCHMARK_OS_FUCHSIA) && !defined(BENCHMARK_OS_QURT)
#include <sys/resource.h>
#endif
#include <sys/time.h>
#include <sys/types.h>  // this header must be included before 'sys/sysctl.h' to avoid compilation error on FreeBSD
#include <unistd.h>
#if defined BENCHMARK_OS_FREEBSD || defined BENCHMARK_OS_DRAGONFLY || \
    defined BENCHMARK_OS_MACOSX
#include <sys/sysctl.h>
#endif
#if defined(BENCHMARK_OS_MACOSX)
#include <mach/mach_init.h>
#include <mach/mach_port.h>
#include <mach/thread_act.h>
#endif
#if defined(BENCHMARK_OS_QURT)
#include <qurt.h>
#endif
#endif

#ifdef BENCHMARK_OS_EMSCRIPTEN
#include <emscripten.h>
#endif

#include <cerrno>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <limits>
#include <mutex>

#include "check.h"
#include "log.h"
#include "sleep.h"
#include "string_util.h"

namespace benchmark {

// Suppress unused warnings on helper functions.
Repository: google/benchmark
File: test/benchmark_min_time_flag_iters_test.cc (C++)

Code before:
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

#include "benchmark/benchmark.h"

// Tests that we can specify the number of iterations with
// --benchmark_min_time=<NUM>x.
namespace {

class TestReporter : public benchmark::ConsoleReporter {
 public:
  virtual bool ReportContext(const Context& context) BENCHMARK_OVERRIDE {
    return ConsoleReporter::ReportContext(context);
  };

  virtual void ReportRuns(const std::vector<Run>& report) BENCHMARK_OVERRIDE {
    assert(report.size() == 1);
    iter_nums_.push_back(static_cast<int>(report[0].iterations));
    ConsoleReporter::ReportRuns(report);
  };

  TestReporter() {}

  virtual ~TestReporter() {}

  const std::vector<int>& GetIters() const { return iter_nums_; }

 private:
  std::vector<int> iter_nums_;
};

}  // end namespace

static void BM_MyBench(benchmark::State& state) {
  for (auto s : state) {
  }
}
BENCHMARK(BM_MyBench);

int main(int argc, char** argv) {
  // Make a fake argv and append the new --benchmark_min_time=<foo> to it.
  int fake_argc = argc + 1;
  const char** fake_argv = new const char*[fake_argc];

Review comment (suggestion):
i think iter_nums_ should probably be a size_t if that's what's being returned by report[0].iterations.

Code after:
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>

#include "benchmark/benchmark.h"

// Tests that we can specify the number of iterations with
// --benchmark_min_time=<NUM>x.
namespace {

class TestReporter : public benchmark::ConsoleReporter {
 public:
  virtual bool ReportContext(const Context& context) BENCHMARK_OVERRIDE {
    return ConsoleReporter::ReportContext(context);
  };

  virtual void ReportRuns(const std::vector<Run>& report) BENCHMARK_OVERRIDE {
    assert(report.size() == 1);
    iter_nums_.push_back(report[0].iterations);
    ConsoleReporter::ReportRuns(report);
  };

  TestReporter() {}

  virtual ~TestReporter() {}

  const std::vector<benchmark::IterationCount>& GetIters() const {
    return iter_nums_;
  }

 private:
  std::vector<benchmark::IterationCount> iter_nums_;
};

}  // end namespace

static void BM_MyBench(benchmark::State& state) {
  for (auto s : state) {
  }
}
BENCHMARK(BM_MyBench);

int main(int argc, char** argv) {
  // Make a fake argv and append the new --benchmark_min_time=<foo> to it.
Repository: google/benchmark
File: .github/libcxx-setup.sh (Shell)

Code before:
#!/usr/bin/env bash

set -e

# Checkout LLVM sources
git clone --depth=1 https://github.com/llvm/llvm-project.git llvm-project

## Setup libc++ options
if [ -z "$BUILD_32_BITS" ]; then
  export BUILD_32_BITS=OFF && echo disabling 32 bit build
fi

## Build and install libc++ (Use unstable ABI for better sanitizer coverage)
cd ./llvm-project/runtimes/
cmake -DCMAKE_C_COMPILER=${CC}                  \
      -DCMAKE_CXX_COMPILER=${CXX}               \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo         \
      -DCMAKE_INSTALL_PREFIX=/usr               \
      -DLIBCXX_ABI_UNSTABLE=OFF                 \
      -DLLVM_USE_SANITIZER=${LIBCXX_SANITIZER}  \
      -DLLVM_BUILD_32_BITS=${BUILD_32_BITS}     \
      -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind' \
      -S llvm -B llvm-build -G "Unix Makefiles"
make -C llvm-build -j3 cxx cxxabi unwind
sudo make -C llvm-build install-cxx install-cxxabi install-unwind
cd ../..

#sudo apt update
#sudo apt -y install libc++-dev libc++abi-dev


Review comment (bug):
One more thing to note, it is rather issue-prone to use libc++ from trunk,
e.g. because nowadays they only guarantee building libc++ with clang
from the same revision or so, so building with older clang may fail,
and i'm not sure that will be caught at cmake time.
So it would be best to checkout some specific tag.

Code after:
#!/usr/bin/env bash

set -e

# Checkout LLVM sources
git clone --depth=1 https://github.com/llvm/llvm-project.git llvm-project

## Setup libc++ options
if [ -z "$BUILD_32_BITS" ]; then
  export BUILD_32_BITS=OFF && echo disabling 32 bit build
fi

## Build and install libc++ (Use unstable ABI for better sanitizer coverage)
mkdir llvm-build && cd llvm-build
cmake -DCMAKE_C_COMPILER=${CC}                  \
      -DCMAKE_CXX_COMPILER=${CXX}               \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo         \
      -DCMAKE_INSTALL_PREFIX=/usr               \
      -DLIBCXX_ABI_UNSTABLE=OFF                 \
      -DLLVM_USE_SANITIZER=${LIBCXX_SANITIZER}  \
      -DLLVM_BUILD_32_BITS=${BUILD_32_BITS}     \
      -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind' \
      -G "Unix Makefiles" \
      ../llvm-project/runtimes/
make -j cxx cxxabi unwind
cd ..
Repository: google/benchmark
File: test/string_util_gtest.cc (C++)

Code before:
//===---------------------------------------------------------------------===//
// string_util_test - Unit tests for src/string_util.cc
//===---------------------------------------------------------------------===//

#include <tuple>

#include "../src/internal_macros.h"
#include "../src/string_util.cc"
#include "../src/string_util.h"
#include "gtest/gtest.h"

namespace {
TEST(StringUtilTest, stoul) {
  {
    size_t pos = 0;
    EXPECT_EQ(0ul, benchmark::stoul("0", &pos));
    EXPECT_EQ(1ul, pos);
  }
  {
    size_t pos = 0;
    EXPECT_EQ(7ul, benchmark::stoul("7", &pos));
    EXPECT_EQ(1ul, pos);
  }
  {
    size_t pos = 0;
    EXPECT_EQ(135ul, benchmark::stoul("135", &pos));
    EXPECT_EQ(3ul, pos);
  }
#if ULONG_MAX == 0xFFFFFFFFul
  {
    size_t pos = 0;
    EXPECT_EQ(0xFFFFFFFFul, benchmark::stoul("4294967295", &pos));
    EXPECT_EQ(10ul, pos);

Review comment (suggestion):
you shouldn't need to do this, ever.  if you need to test a function, make it part of the public API.  but ideally, test the public API instead.

Code after:
//===---------------------------------------------------------------------===//
// string_util_test - Unit tests for src/string_util.cc
//===---------------------------------------------------------------------===//

#include <tuple>

#include "../src/internal_macros.h"
#include "../src/string_util.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

namespace {
TEST(StringUtilTest, stoul) {
  {
    size_t pos = 0;
    EXPECT_EQ(0ul, benchmark::stoul("0", &pos));
    EXPECT_EQ(1ul, pos);
  }
  {
    size_t pos = 0;
    EXPECT_EQ(7ul, benchmark::stoul("7", &pos));
    EXPECT_EQ(1ul, pos);
  }
  {
    size_t pos = 0;
    EXPECT_EQ(135ul, benchmark::stoul("135", &pos));
    EXPECT_EQ(3ul, pos);
  }
#if ULONG_MAX == 0xFFFFFFFFul
  {
    size_t pos = 0;
    EXPECT_EQ(0xFFFFFFFFul, benchmark::stoul("4294967295", &pos));
    EXPECT_EQ(10ul, pos);
Repository: google/benchmark
File: src/string_util.h (C/C++)

Code before:
}

BENCHMARK_EXPORT
std::vector<std::string> StrSplit(const std::string& str, char delim);

// Disable lint checking for this block since it re-implements C functions.
// NOLINTBEGIN
#ifdef BENCHMARK_STL_ANDROID_GNUSTL
/*
 * GNU STL in Android NDK lacks support for some C++11 functions, including
 * stoul, stoi, stod. We reimplement them here using C functions strtoul,
 * strtol, strtod. Note that reimplemented functions are in benchmark::
 * namespace, not std:: namespace.
 */
unsigned long stoul(const std::string& str, size_t* pos = nullptr,
                    int base = 10);
int stoi(const std::string& str, size_t* pos = nullptr, int base = 10);
double stod(const std::string& str, size_t* pos = nullptr);
#else
using std::stod;   // NOLINT(misc-unused-using-decls)
using std::stoi;   // NOLINT(misc-unused-using-decls)
using std::stoul;  // NOLINT(misc-unused-using-decls)
#endif
// NOLINTEND

}  // end namespace benchmark
#endif  // BENCHMARK_STRING_UTIL_H_

Review comment (suggestion):
```diff
-} // end namespace benchmark
-#endif  // BENCHMARK_STRING_UTIL_H_
+} // end namespace benchmark
+
+#endif  // BENCHMARK_STRING_UTIL_H_
+
```


Code after:
}

BENCHMARK_EXPORT
std::vector<std::string> StrSplit(const std::string& str, char delim);

// Disable lint checking for this block since it re-implements C functions.
// NOLINTBEGIN
#ifdef BENCHMARK_STL_ANDROID_GNUSTL
/*
 * GNU STL in Android NDK lacks support for some C++11 functions, including
 * stoul, stoi, stod. We reimplement them here using C functions strtoul,
 * strtol, strtod. Note that reimplemented functions are in benchmark::
 * namespace, not std:: namespace.
 */
unsigned long stoul(const std::string& str, size_t* pos = nullptr,
                    int base = 10);
int stoi(const std::string& str, size_t* pos = nullptr, int base = 10);
double stod(const std::string& str, size_t* pos = nullptr);
#else
using std::stod;   // NOLINT(misc-unused-using-decls)
using std::stoi;   // NOLINT(misc-unused-using-decls)
using std::stoul;  // NOLINT(misc-unused-using-decls)
#endif
// NOLINTEND

}  // end namespace benchmark

#endif  // BENCHMARK_STRING_UTIL_H_
Repository: google/benchmark
File: test/string_util_gtest.cc (C++)

Code before:
        std::make_tuple(1024.0, benchmark::Counter::kIs1024, "1Ki"),
        std::make_tuple(1000 * 1000.0, benchmark::Counter::kIs1024,
                        "976\\.56.Ki"),
        std::make_tuple(1024 * 1024.0, benchmark::Counter::kIs1024, "1Mi"),
        std::make_tuple(1000 * 1000 * 1000.0, benchmark::Counter::kIs1024,
                        "953\\.674Mi"),
        std::make_tuple(1024 * 1024 * 1024.0, benchmark::Counter::kIs1024,
                        "1Gi"),
        std::make_tuple(0.0, benchmark::Counter::kIs1000, "0"),
        std::make_tuple(999.0, benchmark::Counter::kIs1000, "999"),
        std::make_tuple(1000.0, benchmark::Counter::kIs1000, "1k"),
        std::make_tuple(1024.0, benchmark::Counter::kIs1000, "1.024k"),
        std::make_tuple(1000 * 1000.0, benchmark::Counter::kIs1000, "1M"),
        std::make_tuple(1024 * 1024.0, benchmark::Counter::kIs1000,
                        "1\\.04858M"),
        std::make_tuple(1000 * 1000 * 1000.0, benchmark::Counter::kIs1000,
                        "1G"),
        std::make_tuple(1024 * 1024 * 1024.0, benchmark::Counter::kIs1000,
                        "1\\.07374G")));

TEST_P(HumanReadableFixture, HumanReadableNumber) {
  std::string str = benchmark::HumanReadableNumber(std::get<0>(GetParam()),
                                                   std::get<1>(GetParam()));
  ASSERT_THAT(str, ::testing::MatchesRegex(std::get<2>(GetParam())));
}
}  // end namespace

Review comment (suggestion):
```diff
-}
-}  // end namespace
+}
+
+}  // end namespace
+
```

Code after:
        std::make_tuple(1024.0, benchmark::Counter::kIs1024, "1Ki"),
        std::make_tuple(1000 * 1000.0, benchmark::Counter::kIs1024,
                        "976\\.56.Ki"),
        std::make_tuple(1024 * 1024.0, benchmark::Counter::kIs1024, "1Mi"),
        std::make_tuple(1000 * 1000 * 1000.0, benchmark::Counter::kIs1024,
                        "953\\.674Mi"),
        std::make_tuple(1024 * 1024 * 1024.0, benchmark::Counter::kIs1024,
                        "1Gi"),
        std::make_tuple(0.0, benchmark::Counter::kIs1000, "0"),
        std::make_tuple(999.0, benchmark::Counter::kIs1000, "999"),
        std::make_tuple(1000.0, benchmark::Counter::kIs1000, "1k"),
        std::make_tuple(1024.0, benchmark::Counter::kIs1000, "1.024k"),
        std::make_tuple(1000 * 1000.0, benchmark::Counter::kIs1000, "1M"),
        std::make_tuple(1024 * 1024.0, benchmark::Counter::kIs1000,
                        "1\\.04858M"),
        std::make_tuple(1000 * 1000 * 1000.0, benchmark::Counter::kIs1000,
                        "1G"),
        std::make_tuple(1024 * 1024 * 1024.0, benchmark::Counter::kIs1000,
                        "1\\.07374G")));

TEST_P(HumanReadableFixture, HumanReadableNumber) {
  std::string str = benchmark::HumanReadableNumber(std::get<0>(GetParam()),
                                                   std::get<1>(GetParam()));
  ASSERT_THAT(str, ::testing::MatchesRegex(std::get<2>(GetParam())));
}

}  // end namespace
Repository: google/benchmark
File: src/benchmark.cc (C++)

Code before:
#if defined(__INTEL_COMPILER)
#pragma warning pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#if defined(__NVCC__)
#pragma nv_diagnostic pop
#endif
#if defined(__NVCOMPILER)
#pragma diagnostic pop
#endif
}

void State::PauseTiming() {
  // Add in time accumulated so far
  BM_CHECK(started_ && !finished_ && !skipped());
  timer_->StopTimer();
  if (perf_counters_measurement_) {
    std::vector<std::pair<std::string, double>> measurements;
    if (!perf_counters_measurement_->Stop(measurements)) {
      BM_CHECK(false) << "Perf counters read the value failed.";
    }
    for (const auto& name_and_measurement : measurements) {
      auto name = name_and_measurement.first;
      auto measurement = name_and_measurement.second;
      BM_CHECK_EQ(std::fpclassify(double{counters[name]}), FP_ZERO);
      counters[name] += Counter(measurement, Counter::kAvgIterations);
    }
  }
}

void State::ResumeTiming() {
  BM_CHECK(started_ && !finished_ && !skipped());
  timer_->StartTimer();
  if (perf_counters_measurement_) {
    perf_counters_measurement_->Start();
  }
}

void State::SkipWithMessage(const std::string& msg) {
  skipped_ = internal::SkippedWithMessage;
  {
    MutexLock l(manager_->GetBenchmarkMutex());
    if (internal::NotSkipped == manager_->results.skipped_) {
      manager_->results.skip_message_ = msg;
      manager_->results.skipped_ = skipped_;
    }
  }
  total_iterations_ = 0;
  if (timer_->running()) timer_->StopTimer();
}

Review comment (suggestion):
I don't believe this assertion remains valid after this change.
Or, for that matter, i'm not sure it ever was valid in the presence of pause-resume-pause sequence.

Code after:
#if defined(__INTEL_COMPILER)
#pragma warning pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
#if defined(__NVCC__)
#pragma nv_diagnostic pop
#endif
#if defined(__NVCOMPILER)
#pragma diagnostic pop
#endif
}

void State::PauseTiming() {
  // Add in time accumulated so far
  BM_CHECK(started_ && !finished_ && !skipped());
  timer_->StopTimer();
  if (perf_counters_measurement_) {
    std::vector<std::pair<std::string, double>> measurements;
    if (!perf_counters_measurement_->Stop(measurements)) {
      BM_CHECK(false) << "Perf counters read the value failed.";
    }
    for (const auto& name_and_measurement : measurements) {
      auto name = name_and_measurement.first;
      auto measurement = name_and_measurement.second;
      counters[name] += Counter(measurement, Counter::kAvgIterations);
    }
  }
}

void State::ResumeTiming() {
  BM_CHECK(started_ && !finished_ && !skipped());
  timer_->StartTimer();
  if (perf_counters_measurement_) {
    perf_counters_measurement_->Start();
  }
}

void State::SkipWithMessage(const std::string& msg) {
  skipped_ = internal::SkippedWithMessage;
  {
    MutexLock l(manager_->GetBenchmarkMutex());
    if (internal::NotSkipped == manager_->results.skipped_) {
      manager_->results.skip_message_ = msg;
      manager_->results.skipped_ = skipped_;
    }
  }
  total_iterations_ = 0;
  if (timer_->running()) timer_->StopTimer();
}
Repository: google/benchmark
File: test/perf_counters_test.cc (C++)

Code before:
  for (auto _ : state) {
    for (auto i = 0; i < kIters; ++i) {
      n = 1 - n;
      benchmark::DoNotOptimize(n);
    }

    state.PauseTiming();
    for (auto j = 0; j < kIters; ++j) {
      m = 1 - m;
      benchmark::DoNotOptimize(m);
    }
    state.ResumeTiming();
  }
}

BENCHMARK(BM_WithPauseResume);

ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_WithPauseResume\",$"}});

static void CheckSimple(Results const& e) {
  CHECK_COUNTER_VALUE(e, double, "CYCLES", GT, 0);
  CHECK_COUNTER_VALUE(e, double, "BRANCHES", GT, 0.0);
}

static void CheckInstrCount(Results const& e) {
  CHECK_COUNTER_VALUE(e, double, "INSTRUCTIONS", GT, kIters);
}

CHECK_BENCHMARK_RESULTS("BM_Simple", &CheckSimple);
CHECK_BENCHMARK_RESULTS("BM_WithoutPauseResume", &CheckInstrCount);
CHECK_BENCHMARK_RESULTS("BM_WithPauseResume", &CheckInstrCount);

int main(int argc, char* argv[]) {
  if (!benchmark::internal::PerfCounters::kSupported) {
    return 0;
  }
  benchmark::FLAGS_benchmark_perf_counters = "CYCLES,BRANCHES,INSTRUCTIONS";
  benchmark::internal::PerfCounters::Initialize();
  RunOutputTests(argc, argv);
}


Review comment (bug):
with pause and resume, shouldn't this be GT 2*kIters?  i don't know how the INSTRUCTIONS perf counters work so i could be wrong.

Code after:
  for (auto _ : state) {
    for (auto i = 0; i < kIters; ++i) {
      n = 1 - n;
      benchmark::DoNotOptimize(n);
    }

    state.PauseTiming();
    for (auto j = 0; j < kIters; ++j) {
      m = 1 - m;
      benchmark::DoNotOptimize(m);
    }
    state.ResumeTiming();
  }
}

BENCHMARK(BM_WithPauseResume);

ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_WithPauseResume\",$"}});

static void CheckSimple(Results const& e) {
  CHECK_COUNTER_VALUE(e, double, "CYCLES", GT, 0);
  CHECK_COUNTER_VALUE(e, double, "BRANCHES", GT, 0.0);
}

double withoutPauseResumeInstrCount = 0.0;
double withPauseResumeInstrCount = 0.0;

static void CheckInstrCount(double* counter, Results const& e) {
  BM_CHECK_GT(e.NumIterations(), 0);
  *counter = e.GetAs<double>("INSTRUCTIONS") / e.NumIterations();
}

static void CheckInstrCountWithoutResume(Results const& e) {
  CheckInstrCount(&withoutPauseResumeInstrCount, e);
}

static void CheckInstrCountWithResume(Results const& e) {
  CheckInstrCount(&withPauseResumeInstrCount, e);
}

CHECK_BENCHMARK_RESULTS("BM_Simple", &CheckSimple);
CHECK_BENCHMARK_RESULTS("BM_WithoutPauseResume", &CheckInstrCountWithoutResume);
CHECK_BENCHMARK_RESULTS("BM_WithPauseResume", &CheckInstrCountWithResume);

int main(int argc, char* argv[]) {
  if (!benchmark::internal::PerfCounters::kSupported) {
    return 0;
  }
  benchmark::FLAGS_benchmark_perf_counters = "CYCLES,BRANCHES,INSTRUCTIONS";
  benchmark::internal::PerfCounters::Initialize();
  RunOutputTests(argc, argv);
Repository: google/benchmark
File: src/timers.h (C/C++)

Code before:

template <>
struct ChooseSteadyClock<false> {
  typedef std::chrono::steady_clock type;
};
#endif  // HAVE_STEADY_CLOCK

#endif

struct ChooseClockType {
#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;
#endif
};

inline double ChronoClockNow() {
  typedef ChooseClockType::type ClockType;
  using FpSeconds = std::chrono::duration<double, std::chrono::seconds::period>;
  return FpSeconds(ClockType::now().time_since_epoch()).count();
}


std::string LocalDateTimeString();

}  // end namespace benchmark

#endif  // BENCHMARK_TIMERS_H


Review comment (bug):
Nit: extra newline (you've used different clang-format version maybe, just apply diff from failed job)

Code after:

template <>
struct ChooseSteadyClock<false> {
  typedef std::chrono::steady_clock type;
};
#endif  // HAVE_STEADY_CLOCK

#endif

struct ChooseClockType {
#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;
#endif
};

inline double ChronoClockNow() {
  typedef ChooseClockType::type ClockType;
  using FpSeconds = std::chrono::duration<double, std::chrono::seconds::period>;
  return FpSeconds(ClockType::now().time_since_epoch()).count();
}

std::string LocalDateTimeString();

}  // end namespace benchmark

#endif  // BENCHMARK_TIMERS_H