Commit 2a05f248 by Disconnect3d Committed by Dominic Hamon

Improve README's basic usage example (#433)

parent 24b80427
...@@ -18,6 +18,8 @@ IRC channel: https://freenode.net #googlebenchmark ...@@ -18,6 +18,8 @@ IRC channel: https://freenode.net #googlebenchmark
Define a function that executes the code to be measured. Define a function that executes the code to be measured.
```c++ ```c++
#include <benchmark/benchmark.h>
static void BM_StringCreation(benchmark::State& state) { static void BM_StringCreation(benchmark::State& state) {
while (state.KeepRunning()) while (state.KeepRunning())
std::string empty_string; std::string empty_string;
...@@ -36,6 +38,8 @@ BENCHMARK(BM_StringCopy); ...@@ -36,6 +38,8 @@ BENCHMARK(BM_StringCopy);
BENCHMARK_MAIN(); BENCHMARK_MAIN();
``` ```
Don't forget to inform your linker to add benchmark library e.g. through `-lbenchmark` compilation flag.
### Passing arguments ### Passing arguments
Sometimes a family of benchmarks can be implemented with just one routine that 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 takes an extra argument to specify which one of the family of benchmarks to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment