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
35da167b
Commit
35da167b
authored
Jun 05, 2014
by
Dominic Hamon
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #28 from pleroy/PausePure
Take the CPU time into account in PauseTiming/ResumeTiming
parents
5c457b06
fe1b75b8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
benchmark.h
include/benchmark/benchmark.h
+4
-2
benchmark.cc
src/benchmark.cc
+20
-10
No files found.
include/benchmark/benchmark.h
View file @
35da167b
...
...
@@ -276,8 +276,10 @@ class State {
double
start_time_
;
int64_t
stop_time_micros_
;
double
start_pause_
;
double
pause_time_
;
double
start_pause_cpu_
;
double
pause_cpu_time_
;
double
start_pause_real_
;
double
pause_real_time_
;
// Total number of iterations for all finished runs.
int64_t
total_iterations_
;
...
...
src/benchmark.cc
View file @
35da167b
...
...
@@ -962,8 +962,10 @@ State::State(FastClock* clock, SharedState* s, int t)
start_cpu_
(
0.0
),
start_time_
(
0.0
),
stop_time_micros_
(
0.0
),
start_pause_
(
0.0
),
pause_time_
(
0.0
),
start_pause_cpu_
(
0.0
),
pause_cpu_time_
(
0.0
),
start_pause_real_
(
0.0
),
pause_real_time_
(
0.0
),
total_iterations_
(
0
),
interval_micros_
(
static_cast
<
int64_t
>
(
kNumMicrosPerSecond
*
FLAGS_benchmark_min_time
/
...
...
@@ -978,7 +980,7 @@ bool State::KeepRunning() {
// Fast path
if
((
FLAGS_benchmark_iterations
==
0
&&
!
clock_
->
HasReached
(
stop_time_micros_
+
kNumMicrosPerSecond
*
pause_time_
))
||
kNumMicrosPerSecond
*
pause_
real_
time_
))
||
iterations_
<
FLAGS_benchmark_iterations
)
{
++
iterations_
;
return
true
;
...
...
@@ -1025,9 +1027,15 @@ bool State::KeepRunning() {
return
ret
;
}
void
State
::
PauseTiming
()
{
start_pause_
=
walltime
::
Now
();
}
void
State
::
PauseTiming
()
{
start_pause_cpu_
=
MyCPUUsage
()
+
ChildrenCPUUsage
();
start_pause_real_
=
walltime
::
Now
();
}
void
State
::
ResumeTiming
()
{
pause_time_
+=
walltime
::
Now
()
-
start_pause_
;
}
void
State
::
ResumeTiming
()
{
pause_cpu_time_
+=
MyCPUUsage
()
+
ChildrenCPUUsage
()
-
start_pause_cpu_
;
pause_real_time_
+=
walltime
::
Now
()
-
start_pause_real_
;
}
void
State
::
SetBytesProcessed
(
int64_t
bytes
)
{
CHECK_EQ
(
STATE_STOPPED
,
state_
);
...
...
@@ -1104,7 +1112,8 @@ void State::NewInterval() {
<<
"
\n
"
;
#endif
iterations_
=
0
;
pause_time_
=
0
;
pause_cpu_time_
=
0
;
pause_real_time_
=
0
;
start_cpu_
=
MyCPUUsage
()
+
ChildrenCPUUsage
();
start_time_
=
walltime
::
Now
();
}
else
{
...
...
@@ -1136,11 +1145,12 @@ bool State::FinishInterval() {
const
double
accumulated_time
=
walltime
::
Now
()
-
start_time_
;
const
double
total_overhead
=
overhead
*
iterations_
;
CHECK_LT
(
pause_time_
,
accumulated_time
);
CHECK_LT
(
pause_time_
+
total_overhead
,
accumulated_time
);
CHECK_LT
(
pause_
real_
time_
,
accumulated_time
);
CHECK_LT
(
pause_
real_
time_
+
total_overhead
,
accumulated_time
);
data
.
real_accumulated_time
=
accumulated_time
-
(
pause_time_
+
total_overhead
);
data
.
cpu_accumulated_time
=
(
MyCPUUsage
()
+
ChildrenCPUUsage
())
-
start_cpu_
;
accumulated_time
-
(
pause_real_time_
+
total_overhead
);
data
.
cpu_accumulated_time
=
(
MyCPUUsage
()
+
ChildrenCPUUsage
())
-
(
pause_cpu_time_
+
start_cpu_
);
total_iterations_
+=
iterations_
;
bool
keep_going
=
false
;
...
...
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