C++ Benchmark
No submission language available for this problem.
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
打开右侧在线编程模式使用自测功能运行。
#include <benchmark/benchmark.h>
static void BM_StringCreation(benchmark::State& state) {
for (auto _ : state)
std::string empty_string;
}
// Register the function as a benchmark
BENCHMARK(BM_StringCreation);
// Define another benchmark
static void BM_StringCopy(benchmark::State& state) {
std::string x = "hello";
for (auto _ : state)
std::string copy(x);
}
BENCHMARK(BM_StringCopy);
BENCHMARK_MAIN();
测试比赛
- Status
- Done
- Rule
- OI
- Problem
- 2
- Start at
- 2025-11-5 19:15
- End at
- 2025-11-5 21:15
- Duration
- 2 hour(s)
- Host
- Partic.
- 0