Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
benchmark
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
benchmark
Commits
cd525ae8
Commit
cd525ae8
authored
Dec 30, 2015
by
Dominic Hamon
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #171 from eliben/update-doc-userealtime
Update README to mention UseRealTime for wallclock time measurements.
parents
f662e8be
c7ab1b98
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
README.md
README.md
+14
-3
benchmark_api.h
include/benchmark/benchmark_api.h
+5
-5
No files found.
README.md
View file @
cd525ae8
...
...
@@ -145,9 +145,10 @@ Three macros are provided for adding benchmark templates.
#define BENCHMARK_TEMPLATE2(func, arg1, arg2)
```
In a multithreaded test, it is guaranteed that none of the threads will start
until all have called KeepRunning, and all will have finished before KeepRunning
returns false. As such, any global setup or teardown you want to do can be
In a multithreaded test (benchmark invoked by multiple threads simultaneously),
it is guaranteed that none of the threads will start until all have called
KeepRunning, and all will have finished before KeepRunning returns false. As
such, any global setup or teardown you want to do can be
wrapped in a check against the thread index:
```
c++
...
...
@@ -165,6 +166,16 @@ static void BM_MultiThreaded(benchmark::State& state) {
BENCHMARK
(
BM_MultiThreaded
)
->
Threads
(
2
);
```
If the benchmarked code itself uses threads and you want to compare it to
single-threaded code, you may want to use real-time ("wallclock") measurements
for latency comparisons:
```
c++
BENCHMARK
(
BM_test
)
->
Range
(
8
,
8
<<
10
)
->
UseRealTime
();
```
Without
`UseRealTime`
, CPU time is used by default.
To prevent a value or expression from being optimized away by the compiler
the
`benchmark::DoNotOptimize(...)`
function can be used.
...
...
include/benchmark/benchmark_api.h
View file @
cd525ae8
...
...
@@ -417,11 +417,11 @@ public:
// option overrides the `benchmark_min_time` flag.
Benchmark
*
MinTime
(
double
t
);
// If a particular benchmark is I/O bound,
or if for some reason CPU
//
timings are not representative, call this method. If called, the elapsed
//
time will be used to control how many iterations are run, and in th
e
//
printing of items/second or MB/seconds values. If not called, the cpu
// time used by the benchmark will be used.
// If a particular benchmark is I/O bound,
runs multiple threads internally or
//
if for some reason CPU timings are not representative, call this method. If
//
called, the elapsed time will be used to control how many iterations ar
e
//
run, and in the printing of items/second or MB/seconds values. If not
//
called, the cpu
time used by the benchmark will be used.
Benchmark
*
UseRealTime
();
// Support for running multiple copies of the same benchmark concurrently
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment