Improve README's basic usage example (#433)

This commit is contained in:
Disconnect3d 2017-09-14 09:31:35 +02:00 committed by Dominic Hamon
parent 24b8042733
commit 2a05f248be
1 changed files with 4 additions and 0 deletions

View File

@ -18,6 +18,8 @@ IRC channel: https://freenode.net #googlebenchmark
Define a function that executes the code to be measured.
```c++
#include <benchmark/benchmark.h>
static void BM_StringCreation(benchmark::State& state) {
while (state.KeepRunning())
std::string empty_string;
@ -36,6 +38,8 @@ BENCHMARK(BM_StringCopy);
BENCHMARK_MAIN();
```
Don't forget to inform your linker to add benchmark library e.g. through `-lbenchmark` compilation flag.
### Passing arguments
Sometimes a family of benchmarks can be implemented with just one routine that
takes an extra argument to specify which one of the family of benchmarks to