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
64b5f3ff
Commit
64b5f3ff
authored
May 01, 2017
by
Joao Paulo Magalhaes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Results::GetTime() receive an enum.
parent
62b1dd9c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
output_test.h
test/output_test.h
+10
-6
output_test_helper.cc
test/output_test_helper.cc
+4
-2
No files found.
test/output_test.h
View file @
64b5f3ff
...
...
@@ -96,13 +96,20 @@ struct Results {
int
NumThreads
()
const
;
// get the real_time duration of the benchmark in seconds
typedef
enum
{
kCpuTime
,
kRealTime
}
BenchmarkTime
;
// get cpu_time or real_time in seconds
double
GetTime
(
BenchmarkTime
which
)
const
;
// get the real_time duration of the benchmark in seconds.
// it is better to use fuzzy float checks for this, as the float
// ASCII formatting is lossy.
double
DurationRealTime
()
const
{
return
GetAs
<
double
>
(
"iterations"
)
*
GetTime
(
"real_time"
);
return
GetAs
<
double
>
(
"iterations"
)
*
GetTime
(
kRealTime
);
}
// get the cpu_time duration of the benchmark in seconds
double
DurationCPUTime
()
const
{
return
GetAs
<
double
>
(
"iterations"
)
*
GetTime
(
"cpu_time"
);
return
GetAs
<
double
>
(
"iterations"
)
*
GetTime
(
kCpuTime
);
}
// get the string for a result by name, or nullptr if the name
...
...
@@ -126,9 +133,6 @@ struct Results {
T
tval
=
static_cast
<
T
>
(
dval
);
return
tval
;
}
// get cpu_time or real_time in seconds
double
GetTime
(
const
char
*
which
)
const
;
};
template
<
class
T
>
...
...
test/output_test_helper.cc
View file @
64b5f3ff
...
...
@@ -303,8 +303,10 @@ int Results::NumThreads() const {
return
num
;
}
double
Results
::
GetTime
(
const
char
*
which
)
const
{
double
val
=
GetAs
<
double
>
(
which
);
double
Results
::
GetTime
(
BenchmarkTime
which
)
const
{
CHECK
(
which
==
kCpuTime
||
which
==
kRealTime
);
const
char
*
which_str
=
which
==
kCpuTime
?
"cpu_time"
:
"real_time"
;
double
val
=
GetAs
<
double
>
(
which_str
);
auto
unit
=
Get
(
"time_unit"
);
CHECK
(
unit
);
if
(
*
unit
==
"ns"
)
{
...
...
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