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
725f1f06
Commit
725f1f06
authored
Mar 26, 2015
by
Eric Fiselier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add walltime benchmark and fix unused variable.
parent
be993acb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
13 deletions
+26
-13
walltime.cc
src/walltime.cc
+18
-9
walltime.h
src/walltime.h
+2
-0
CMakeLists.txt
test/CMakeLists.txt
+2
-0
basic_test.cc
test/basic_test.cc
+4
-4
No files found.
src/walltime.cc
View file @
725f1f06
...
@@ -145,6 +145,21 @@ WallTimeImp::WallTimeImp()
...
@@ -145,6 +145,21 @@ WallTimeImp::WallTimeImp()
}
// end anonymous namespace
}
// end anonymous namespace
WallTime
CPUWalltimeNow
()
{
static
WallTimeImp
&
imp
=
WallTimeImp
::
GetWallTimeImp
();
return
imp
.
Now
();
}
WallTime
ChronoWalltimeNow
()
{
typedef
std
::
chrono
::
system_clock
Clock
;
typedef
std
::
chrono
::
duration
<
WallTime
,
std
::
chrono
::
seconds
::
period
>
FPSeconds
;
static_assert
(
std
::
chrono
::
treat_as_floating_point
<
WallTime
>::
value
,
"This type must be treated as a floating point type."
);
auto
now
=
Clock
::
now
().
time_since_epoch
();
return
std
::
chrono
::
duration_cast
<
FPSeconds
>
(
now
).
count
();
}
// WallTimeImp doesn't work when CPU Scaling is enabled. If CPU Scaling is
// WallTimeImp doesn't work when CPU Scaling is enabled. If CPU Scaling is
// enabled at the start of the program then std::chrono::system_clock is used
// enabled at the start of the program then std::chrono::system_clock is used
// instead.
// instead.
...
@@ -152,16 +167,9 @@ WallTime Now()
...
@@ -152,16 +167,9 @@ WallTime Now()
{
{
static
bool
useWallTime
=
!
CpuScalingEnabled
();
static
bool
useWallTime
=
!
CpuScalingEnabled
();
if
(
useWallTime
)
{
if
(
useWallTime
)
{
static
WallTimeImp
&
imp
=
WallTimeImp
::
GetWallTimeImp
();
return
CPUWalltimeNow
();
return
imp
.
Now
();
}
else
{
}
else
{
typedef
std
::
chrono
::
system_clock
Clock
;
return
ChronoWalltimeNow
();
typedef
std
::
chrono
::
duration
<
WallTime
,
std
::
chrono
::
seconds
::
period
>
FPSeconds
;
static_assert
(
std
::
chrono
::
treat_as_floating_point
<
WallTime
>::
value
,
"This type must be treated as a floating point type."
);
auto
now
=
Clock
::
now
().
time_since_epoch
();
return
std
::
chrono
::
duration_cast
<
FPSeconds
>
(
now
).
count
();
}
}
}
}
...
@@ -185,6 +193,7 @@ std::string DateTimeString(bool local) {
...
@@ -185,6 +193,7 @@ std::string DateTimeString(bool local) {
}
}
std
::
size_t
written
=
std
::
strftime
(
storage
,
sizeof
(
storage
),
"%F %T"
,
&
timeinfo
);
std
::
size_t
written
=
std
::
strftime
(
storage
,
sizeof
(
storage
),
"%F %T"
,
&
timeinfo
);
CHECK
(
written
<
arraysize
(
storage
));
CHECK
(
written
<
arraysize
(
storage
));
((
void
)
written
);
// prevent unused variable in optimized mode.
return
std
::
string
(
storage
);
return
std
::
string
(
storage
);
}
}
...
...
src/walltime.h
View file @
725f1f06
...
@@ -7,6 +7,8 @@ namespace benchmark {
...
@@ -7,6 +7,8 @@ namespace benchmark {
typedef
double
WallTime
;
typedef
double
WallTime
;
namespace
walltime
{
namespace
walltime
{
WallTime
CPUWalltimeNow
();
WallTime
ChronoWalltimeNow
();
WallTime
Now
();
WallTime
Now
();
}
// end namespace walltime
}
// end namespace walltime
...
...
test/CMakeLists.txt
View file @
725f1f06
...
@@ -32,3 +32,5 @@ compile_benchmark_test(cxx03_test)
...
@@ -32,3 +32,5 @@ compile_benchmark_test(cxx03_test)
set_target_properties
(
cxx03_test
set_target_properties
(
cxx03_test
PROPERTIES COMPILE_FLAGS
"
${
CXX03_FLAGS
}
"
)
PROPERTIES COMPILE_FLAGS
"
${
CXX03_FLAGS
}
"
)
add_test
(
cxx03 cxx03_test
)
add_test
(
cxx03 cxx03_test
)
compile_benchmark_test
(
walltime_test
)
test/basic_test.cc
View file @
725f1f06
...
@@ -65,8 +65,8 @@ void BM_pause_during(benchmark::State& state) {
...
@@ -65,8 +65,8 @@ void BM_pause_during(benchmark::State& state) {
state
.
ResumeTiming
();
state
.
ResumeTiming
();
}
}
}
}
BENCHMARK
_TEST
(
BM_pause_during
);
BENCHMARK
(
BM_pause_during
);
BENCHMARK
_TEST
(
BM_pause_during
)
->
ThreadPerCpu
();
BENCHMARK
(
BM_pause_during
)
->
ThreadPerCpu
();
void
BM_pause_during_realtime
(
benchmark
::
State
&
state
)
{
void
BM_pause_during_realtime
(
benchmark
::
State
&
state
)
{
state
.
UseRealTime
();
state
.
UseRealTime
();
...
@@ -75,8 +75,8 @@ void BM_pause_during_realtime(benchmark::State& state) {
...
@@ -75,8 +75,8 @@ void BM_pause_during_realtime(benchmark::State& state) {
state
.
ResumeTiming
();
state
.
ResumeTiming
();
}
}
}
}
BENCHMARK
_TEST
(
BM_pause_during_realtime
);
BENCHMARK
(
BM_pause_during_realtime
);
BENCHMARK
_TEST
(
BM_pause_during_realtime
)
->
ThreadPerCpu
();
BENCHMARK
(
BM_pause_during_realtime
)
->
ThreadPerCpu
();
void
BM_spin_pause_after
(
benchmark
::
State
&
state
)
{
void
BM_spin_pause_after
(
benchmark
::
State
&
state
)
{
while
(
state
.
KeepRunning
())
{
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