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
d3e0671a
Commit
d3e0671a
authored
Mar 26, 2015
by
Eric Fiselier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish selection of clock with debug information
parent
48c4c9cf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
10 deletions
+47
-10
CMakeLists.txt
CMakeLists.txt
+1
-0
steady_clock.cpp
cmake/steady_clock.cpp
+8
-0
reporter.cc
src/reporter.cc
+1
-1
walltime.cc
src/walltime.cc
+37
-9
No files found.
CMakeLists.txt
View file @
d3e0671a
...
...
@@ -54,6 +54,7 @@ endif()
cxx_feature_check
(
STD_REGEX
)
cxx_feature_check
(
GNU_POSIX_REGEX
)
cxx_feature_check
(
POSIX_REGEX
)
cxx_feature_check
(
STEADY_CLOCK
)
# Set up directories
include_directories
(
${
PROJECT_SOURCE_DIR
}
/include
)
...
...
cmake/steady_clock.cpp
0 → 100644
View file @
d3e0671a
#include <chrono>
int
main
()
{
typedef
std
::
chrono
::
steady_clock
Clock
;
Clock
::
time_point
tp
=
Clock
::
now
();
((
void
)
tp
);
}
\ No newline at end of file
src/reporter.cc
View file @
d3e0671a
...
...
@@ -103,7 +103,7 @@ bool ConsoleReporter::ReportContext(const Context& context) {
if
(
context
.
cpu_scaling_enabled
)
{
fprintf
(
stdout
,
"***WARNING*** CPU scaling is enabled, the benchmark "
"timings may be noisy
\n
"
);
"timings may be noisy
and will incure extra overhead.
\n
"
);
}
#ifndef NDEBUG
...
...
src/walltime.cc
View file @
d3e0671a
...
...
@@ -29,6 +29,7 @@
#include "arraysize.h"
#include "check.h"
#include "cycleclock.h"
#include "log.h"
#include "sysinfo.h"
namespace
benchmark
{
...
...
@@ -36,6 +37,26 @@ namespace walltime {
namespace
{
#if defined(HAVE_STEADY_CLOCK)
template
<
bool
HighResIsSteady
=
std
::
chrono
::
high_resolution_clock
::
is_steady
>
struct
ChooseSteadyClock
{
typedef
std
::
chrono
::
high_resolution_clock
type
;
};
template
<>
struct
ChooseSteadyClock
<
false
>
{
typedef
std
::
chrono
::
steady_clock
type
;
};
#endif
struct
ChooseClockType
{
#if defined(HAVE_STEADY_CLOCK)
typedef
typename
ChooseSteadyClock
<>::
type
type
;
#else
typedef
std
::
chrono
::
high_resolution_clock
type
;
#endif
};
class
WallTimeImp
{
public
:
...
...
@@ -151,7 +172,7 @@ WallTime CPUWalltimeNow() {
}
WallTime
ChronoWalltimeNow
()
{
typedef
std
::
chrono
::
system_clock
Clock
;
typedef
ChooseClockType
::
type
Clock
;
typedef
std
::
chrono
::
duration
<
WallTime
,
std
::
chrono
::
seconds
::
period
>
FPSeconds
;
static_assert
(
std
::
chrono
::
treat_as_floating_point
<
WallTime
>::
value
,
...
...
@@ -160,13 +181,23 @@ WallTime ChronoWalltimeNow() {
return
std
::
chrono
::
duration_cast
<
FPSeconds
>
(
now
).
count
();
}
bool
UseCpuCycleClock
()
{
bool
useWallTime
=
!
CpuScalingEnabled
();
if
(
useWallTime
)
{
VLOG
(
1
)
<<
"Using the CPU cycle clock to provide walltime::Now().
\n
"
;
}
else
{
VLOG
(
1
)
<<
"Using std::chrono to provide walltime::Now().
\n
"
;
}
return
useWallTime
;
}
// 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
// instead.
WallTime
Now
()
{
static
bool
use
WallTime
=
!
CpuScalingEnabled
();
if
(
use
WallTime
)
{
static
bool
use
CPUClock
=
UseCpuCycleClock
();
if
(
use
CPUClock
)
{
return
CPUWalltimeNow
();
}
else
{
return
ChronoWalltimeNow
();
...
...
@@ -182,14 +213,11 @@ std::string DateTimeString(bool local) {
char
storage
[
128
];
std
::
tm
timeinfo
;
std
::
memset
(
&
timeinfo
,
0
,
sizeof
(
std
::
tm
));
if
(
local
)
{
std
::
tm
*
ret
=
std
::
localtime
(
&
now
);
CHECK
(
ret
!=
nullptr
);
timeinfo
=
*
ret
;
::
localtime_r
(
&
now
,
&
timeinfo
);
}
else
{
std
::
tm
*
ret
=
std
::
gmtime
(
&
now
);
CHECK
(
ret
!=
nullptr
);
timeinfo
=
*
ret
;
::
gmtime_r
(
&
now
,
&
timeinfo
);
}
std
::
size_t
written
=
std
::
strftime
(
storage
,
sizeof
(
storage
),
"%F %T"
,
&
timeinfo
);
CHECK
(
written
<
arraysize
(
storage
));
...
...
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