Google Benchmark -


Apache
跨平台
C/C++

软件简介

Benchmark 是 Google 一个用来对代码片段进行基准测试的库,类似单元测试,例如:

#include <benchmark/benchmark.h>

static void BM_SomeFunction(benchmark::State& state) {
  // Perform setup here
  for (auto _ : state) {
    // This code gets timed
    SomeFunction();
  }
}
// Register the function as a benchmark
BENCHMARK(BM_SomeFunction);
// Run the benchmark
BENCHMARK_MAIN();