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
80093519
Commit
80093519
authored
Jan 09, 2014
by
Dominic Hamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minimum iteration and overhead support.
Ensure we run at least 1 iteration. Take into account overhead of an empty benchmark. Minor cleanup of code.
parent
2ff306af
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
benchmark.cc
src/benchmark.cc
+12
-10
colorprint.cc
src/colorprint.cc
+1
-1
No files found.
src/benchmark.cc
View file @
80093519
...
@@ -155,7 +155,7 @@ std::string ToBinaryStringFullySpecified(double value, double threshold,
...
@@ -155,7 +155,7 @@ std::string ToBinaryStringFullySpecified(double value, double threshold,
int
precision
)
{
int
precision
)
{
std
::
string
mantissa
;
std
::
string
mantissa
;
int
exponent
;
int
exponent
;
ToExponentAndMantissa
(
value
,
threshold
,
precision
,
1024.
,
&
mantissa
,
ToExponentAndMantissa
(
value
,
threshold
,
precision
,
1024.
0
,
&
mantissa
,
&
exponent
);
&
exponent
);
return
mantissa
+
ExponentToPrefix
(
exponent
,
false
);
return
mantissa
+
ExponentToPrefix
(
exponent
,
false
);
}
}
...
@@ -209,7 +209,7 @@ const char* Prefix() {
...
@@ -209,7 +209,7 @@ const char* Prefix() {
// TODO
// TODO
//static internal::MallocCounter *benchmark_mc;
//static internal::MallocCounter *benchmark_mc;
static
bool
CpuScalingEnabled
()
{
bool
CpuScalingEnabled
()
{
// On Linux, the CPUfreq subsystem exposes CPU information as files on the
// On Linux, the CPUfreq subsystem exposes CPU information as files on the
// local file system. If reading the exported files fails, then we may not be
// local file system. If reading the exported files fails, then we may not be
// running on Linux, so we silently ignore all the read errors.
// running on Linux, so we silently ignore all the read errors.
...
@@ -523,16 +523,17 @@ namespace internal {
...
@@ -523,16 +523,17 @@ namespace internal {
// Information kept per benchmark we may want to run
// Information kept per benchmark we may want to run
struct
Benchmark
::
Instance
{
struct
Benchmark
::
Instance
{
Instance
()
Instance
()
:
rangeXset
(
false
),
rangeX
(
kNoRange
),
:
bm
(
nullptr
),
threads
(
1
),
rangeXset
(
false
),
rangeX
(
kNoRange
),
rangeYset
(
false
),
rangeY
(
kNoRange
)
{}
rangeYset
(
false
),
rangeY
(
kNoRange
)
{}
std
::
string
name
;
std
::
string
name
;
Benchmark
*
bm
;
Benchmark
*
bm
;
int
threads
;
// Number of concurrent threads to use
bool
rangeXset
;
bool
rangeXset
;
int
rangeX
;
int
rangeX
;
bool
rangeYset
;
bool
rangeYset
;
int
rangeY
;
int
rangeY
;
int
threads
;
// Number of concurrent threads to use
bool
multithreaded
()
const
{
return
!
bm
->
thread_counts_
.
empty
();
}
bool
multithreaded
()
const
{
return
!
bm
->
thread_counts_
.
empty
();
}
};
};
...
@@ -682,9 +683,7 @@ std::vector<Benchmark::Instance> Benchmark::CreateBenchmarkInstances(
...
@@ -682,9 +683,7 @@ std::vector<Benchmark::Instance> Benchmark::CreateBenchmarkInstances(
const
bool
is_multithreaded
=
(
!
thread_counts_
.
empty
());
const
bool
is_multithreaded
=
(
!
thread_counts_
.
empty
());
const
std
::
vector
<
int
>&
thread_counts
=
const
std
::
vector
<
int
>&
thread_counts
=
(
is_multithreaded
?
thread_counts_
:
one_thread
);
(
is_multithreaded
?
thread_counts_
:
one_thread
);
for
(
size_t
t
=
0
;
t
<
thread_counts
.
size
();
++
t
)
{
for
(
int
num_threads
:
thread_counts
)
{
int
num_threads
=
thread_counts
[
t
];
Instance
instance
;
Instance
instance
;
instance
.
name
=
name_
;
instance
.
name
=
name_
;
instance
.
bm
=
this
;
instance
.
bm
=
this
;
...
@@ -1002,8 +1001,10 @@ void State::NewInterval() {
...
@@ -1002,8 +1001,10 @@ void State::NewInterval() {
}
}
bool
State
::
FinishInterval
()
{
bool
State
::
FinishInterval
()
{
if
(
FLAGS_benchmark_iterations
!=
0
&&
if
((
FLAGS_benchmark_iterations
!=
0
&&
iterations_
<
FLAGS_benchmark_iterations
/
FLAGS_benchmark_repetitions
)
{
iterations_
<
FLAGS_benchmark_iterations
/
FLAGS_benchmark_repetitions
)
||
iterations_
<
1
)
{
interval_micros_
*=
2
;
interval_micros_
*=
2
;
#ifdef DEBUG
#ifdef DEBUG
std
::
cout
<<
"Not enough iterations in interval; "
std
::
cout
<<
"Not enough iterations in interval; "
...
@@ -1020,7 +1021,8 @@ bool State::FinishInterval() {
...
@@ -1020,7 +1021,8 @@ bool State::FinishInterval() {
data
.
thread_index
=
thread_index
;
data
.
thread_index
=
thread_index
;
const
double
accumulated_time
=
walltime
::
Now
()
-
start_time_
;
const
double
accumulated_time
=
walltime
::
Now
()
-
start_time_
;
const
double
total_overhead
=
0.0
;
// TODO: overhead * iterations_;
const
double
total_overhead
=
overhead
*
iterations_
;
//const double total_overhead = 0.0;
CHECK_LT
(
pause_time_
,
accumulated_time
);
CHECK_LT
(
pause_time_
,
accumulated_time
);
CHECK_LT
(
pause_time_
+
total_overhead
,
accumulated_time
);
CHECK_LT
(
pause_time_
+
total_overhead
,
accumulated_time
);
data
.
real_accumulated_time
=
data
.
real_accumulated_time
=
...
...
src/colorprint.cc
View file @
80093519
...
@@ -53,7 +53,7 @@ void ColorPrintf(LogColor color, const char* fmt, ...) {
...
@@ -53,7 +53,7 @@ void ColorPrintf(LogColor color, const char* fmt, ...) {
#ifdef OS_WINDOWS
#ifdef OS_WINDOWS
const
HANDLE
stdout_handle
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
const
HANDLE
stdout_handle
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
// Gets the current text color.
// Gets the current text color.
CONSOLE_SCREEN_BUFFER_INFO
buffer_info
;
CONSOLE_SCREEN_BUFFER_INFO
buffer_info
;
GetConsoleScreenBufferInfo
(
stdout_handle
,
&
buffer_info
);
GetConsoleScreenBufferInfo
(
stdout_handle
,
&
buffer_info
);
...
...
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