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
c7ab1b98
Commit
c7ab1b98
authored
Dec 30, 2015
by
Eli Bendersky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update README to mention UseRealTime for wallclock time measurements.
Also adding a use case in the API header. Fixes #170
parent
f662e8be
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 @
c7ab1b98
...
@@ -145,9 +145,10 @@ Three macros are provided for adding benchmark templates.
...
@@ -145,9 +145,10 @@ Three macros are provided for adding benchmark templates.
#define BENCHMARK_TEMPLATE2(func, arg1, arg2)
#define BENCHMARK_TEMPLATE2(func, arg1, arg2)
```
```
In a multithreaded test, it is guaranteed that none of the threads will start
In a multithreaded test (benchmark invoked by multiple threads simultaneously),
until all have called KeepRunning, and all will have finished before KeepRunning
it is guaranteed that none of the threads will start until all have called
returns false. As such, any global setup or teardown you want to do can be
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:
wrapped in a check against the thread index:
```
c++
```
c++
...
@@ -165,6 +166,16 @@ static void BM_MultiThreaded(benchmark::State& state) {
...
@@ -165,6 +166,16 @@ static void BM_MultiThreaded(benchmark::State& state) {
BENCHMARK
(
BM_MultiThreaded
)
->
Threads
(
2
);
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
To prevent a value or expression from being optimized away by the compiler
the
`benchmark::DoNotOptimize(...)`
function can be used.
the
`benchmark::DoNotOptimize(...)`
function can be used.
...
...
include/benchmark/benchmark_api.h
View file @
c7ab1b98
...
@@ -417,11 +417,11 @@ public:
...
@@ -417,11 +417,11 @@ public:
// option overrides the `benchmark_min_time` flag.
// option overrides the `benchmark_min_time` flag.
Benchmark
*
MinTime
(
double
t
);
Benchmark
*
MinTime
(
double
t
);
// If a particular benchmark is I/O bound,
or if for some reason CPU
// If a particular benchmark is I/O bound,
runs multiple threads internally or
//
timings are not representative, call this method. If called, the elapsed
//
if for some reason CPU timings are not representative, call this method. If
//
time will be used to control how many iterations are run, and in th
e
//
called, the elapsed time will be used to control how many iterations ar
e
//
printing of items/second or MB/seconds values. If not called, the cpu
//
run, and in the printing of items/second or MB/seconds values. If not
// time used by the benchmark will be used.
//
called, the cpu
time used by the benchmark will be used.
Benchmark
*
UseRealTime
();
Benchmark
*
UseRealTime
();
// Support for running multiple copies of the same benchmark concurrently
// 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