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
7c6a7e30
Commit
7c6a7e30
authored
Mar 11, 2015
by
Eric
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #90 from google/userealtime
Enable UseRealTime and fix documentation for SetLabel.
parents
e975efdb
d68127d8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
benchmark.h
include/benchmark/benchmark.h
+2
-6
benchmark.cc
src/benchmark.cc
+2
-2
benchmark_test.cc
test/benchmark_test.cc
+11
-0
No files found.
include/benchmark/benchmark.h
View file @
7c6a7e30
...
...
@@ -158,10 +158,6 @@ void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter = nullptr);
// ------------------------------------------------------
// Routines that can be called from within a benchmark
//
// REQUIRES: a benchmark is currently executing
void
SetLabel
(
const
std
::
string
&
label
);
// If this routine is called, peak memory allocation past this point in the
// benchmark is reported at the end of the benchmark report line. (It is
// computed by running the benchmark once with a single iteration and a memory
...
...
@@ -212,10 +208,10 @@ class State {
// If this routine is called, the specified label is printed at the
// end of the benchmark report line for the currently executing
// benchmark. Example:
// static void BM_Compress(
int iters
) {
// static void BM_Compress(
benchmark::State& state
) {
// ...
// double compress = input_size / output_size;
//
benchmark::
SetLabel(StringPrintf("compress:%.1f%%", 100.0*compression));
//
state.
SetLabel(StringPrintf("compress:%.1f%%", 100.0*compression));
// }
// Produces output that looks like:
// BM_Compress 50 50 14115038 compress:27.3%
...
...
src/benchmark.cc
View file @
7c6a7e30
...
...
@@ -416,8 +416,6 @@ void MemoryUsage() {
}
*/
void
UseRealTime
()
{
use_real_time
=
true
;
}
void
PrintUsageAndExit
()
{
fprintf
(
stdout
,
"benchmark [--benchmark_filter=<regex>]
\n
"
...
...
@@ -1176,6 +1174,8 @@ void RunSpecifiedBenchmarks(const BenchmarkReporter* reporter /*= nullptr*/) {
spec
,
reporter
==
nullptr
?
&
default_reporter
:
reporter
);
}
void
UseRealTime
()
{
use_real_time
=
true
;
}
void
Initialize
(
int
*
argc
,
const
char
**
argv
)
{
internal
::
ParseCommandLineFlags
(
argc
,
argv
);
internal
::
SetLogLevel
(
FLAGS_v
);
...
...
test/benchmark_test.cc
View file @
7c6a7e30
...
...
@@ -57,6 +57,17 @@ static void BM_Factorial(benchmark::State& state) {
}
BENCHMARK
(
BM_Factorial
);
static
void
BM_FactorialRealTime
(
benchmark
::
State
&
state
)
{
benchmark
::
UseRealTime
();
int
fac_42
=
0
;
while
(
state
.
KeepRunning
())
fac_42
=
Factorial
(
8
);
// Prevent compiler optimizations
std
::
cout
<<
fac_42
;
}
BENCHMARK
(
BM_FactorialRealTime
);
static
void
BM_CalculatePiRange
(
benchmark
::
State
&
state
)
{
double
pi
=
0.0
;
while
(
state
.
KeepRunning
())
...
...
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