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
9a25f472
Commit
9a25f472
authored
Dec 19, 2013
by
Dominic Hamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix printing of time
parent
e390e4eb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
21 deletions
+23
-21
benchmark.cc
src/benchmark.cc
+1
-2
walltime.cc
src/walltime.cc
+15
-14
walltime.h
src/walltime.h
+7
-5
No files found.
src/benchmark.cc
View file @
9a25f472
...
@@ -341,10 +341,9 @@ bool ConsoleReporter::ReportContext(const BenchmarkContextData& context) {
...
@@ -341,10 +341,9 @@ bool ConsoleReporter::ReportContext(const BenchmarkContextData& context) {
<<
((
context
.
num_cpus
>
1
)
?
"s"
:
""
)
<<
"
\n
"
;
<<
((
context
.
num_cpus
>
1
)
?
"s"
:
""
)
<<
"
\n
"
;
int
remainder_ms
;
int
remainder_ms
;
char
time_buf
[
32
];
std
::
cout
<<
walltime
::
Print
(
walltime
::
Now
(),
"%Y/%m/%d-%H:%M:%S"
,
std
::
cout
<<
walltime
::
Print
(
walltime
::
Now
(),
"%Y/%m/%d-%H:%M:%S"
,
true
,
// use local timezone
true
,
// use local timezone
time_buf
,
&
remainder_ms
)
<<
"
\n
"
;
&
remainder_ms
)
<<
"
\n
"
;
// Show details of CPU model, caches, TLBs etc.
// Show details of CPU model, caches, TLBs etc.
// if (!context.cpu_info.empty())
// if (!context.cpu_info.empty())
...
...
src/walltime.cc
View file @
9a25f472
...
@@ -119,21 +119,22 @@ WallTime Now() {
...
@@ -119,21 +119,22 @@ WallTime Now() {
return
now
;
return
now
;
}
}
const
char
*
Print
(
WallTime
time
,
const
char
*
format
,
bool
local
,
std
::
string
Print
(
WallTime
time
,
const
char
*
format
,
bool
local
,
char
*
storage
,
int
*
remainder_us
)
{
int
*
remainder_us
)
{
struct
tm
split
;
char
storage
[
32
];
double
subsecond
;
struct
tm
split
;
if
(
!
SplitTimezone
(
time
,
local
,
&
split
,
&
subsecond
))
{
double
subsecond
;
snprintf
(
storage
,
sizeof
(
storage
),
"Invalid time: %f"
,
time
);
if
(
!
SplitTimezone
(
time
,
local
,
&
split
,
&
subsecond
))
{
}
else
{
snprintf
(
storage
,
sizeof
(
storage
),
"Invalid time: %f"
,
time
);
if
(
remainder_us
!=
NULL
)
{
}
else
{
*
remainder_us
=
static_cast
<
int
>
((
subsecond
*
1000000
)
+
0.5
);
if
(
remainder_us
!=
NULL
)
{
if
(
*
remainder_us
>
999999
)
*
remainder_us
=
999999
;
*
remainder_us
=
static_cast
<
int
>
((
subsecond
*
1000000
)
+
0.5
);
if
(
*
remainder_us
<
0
)
*
remainder_us
=
0
;
if
(
*
remainder_us
>
999999
)
*
remainder_us
=
999999
;
}
if
(
*
remainder_us
<
0
)
*
remainder_us
=
0
;
strftime
(
storage
,
sizeof
(
storage
),
format
,
&
split
);
}
}
return
storage
;
strftime
(
storage
,
sizeof
(
storage
),
format
,
&
split
);
}
return
std
::
string
(
storage
);
}
}
}
// end namespace walltime
}
// end namespace walltime
}
// end namespace benchmark
}
// end namespace benchmark
src/walltime.h
View file @
9a25f472
#ifndef BENCHMARK_WALLTIME_H_
#ifndef BENCHMARK_WALLTIME_H_
#define BENCHMARK_WALLTIME_H_
#define BENCHMARK_WALLTIME_H_
#include <string>
namespace
benchmark
{
namespace
benchmark
{
typedef
double
WallTime
;
typedef
double
WallTime
;
...
@@ -10,11 +12,11 @@ WallTime Now();
...
@@ -10,11 +12,11 @@ WallTime Now();
// GIVEN: walltime, generic format string (as understood by strftime),
// GIVEN: walltime, generic format string (as understood by strftime),
// a boolean flag specifying if the time is local or UTC (true=local).
// a boolean flag specifying if the time is local or UTC (true=local).
// RETURNS: the formatted string. ALSO RETURNS: the
storage printbuffer
// RETURNS: the formatted string. ALSO RETURNS: the
remaining number of
//
passed and the remaining number of microseconds (never printed in
//
microseconds (never printed in the string since strftime does not understand
//
the string since strftime does not understand
it)
// it)
const
char
*
Print
(
WallTime
time
,
const
char
*
format
,
bool
local
,
std
::
string
Print
(
WallTime
time
,
const
char
*
format
,
bool
local
,
char
*
storage
,
int
*
remainder_us
);
int
*
remainder_us
);
}
// end namespace walltime
}
// end namespace walltime
}
// end namespace benchmark
}
// end namespace benchmark
...
...
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