mirror of
https://github.com/google/benchmark.git
synced 2024-12-26 12:30:14 +08:00
Improve README's basic usage example (#433)
This commit is contained in:
parent
24b8042733
commit
2a05f248be
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user