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
6a5bf081
Unverified
Commit
6a5bf081
authored
Jun 24, 2021
by
Dominic Hamon
Committed by
GitHub
Jun 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prefix macros to avoid clashes (#1186)
parent
5da56604
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
154 additions
and
150 deletions
+154
-150
benchmark.cc
src/benchmark.cc
+25
-24
benchmark_register.cc
src/benchmark_register.cc
+25
-25
benchmark_register.h
src/benchmark_register.h
+9
-9
benchmark_runner.cc
src/benchmark_runner.cc
+2
-2
benchmark_runner.h
src/benchmark_runner.h
+5
-5
check.h
src/check.h
+20
-19
colorprint.cc
src/colorprint.cc
+2
-2
commandlineflags.h
src/commandlineflags.h
+10
-10
complexity.cc
src/complexity.cc
+5
-4
csv_reporter.cc
src/csv_reporter.cc
+2
-1
mutex.h
src/mutex.h
+1
-1
perf_counters.h
src/perf_counters.h
+1
-1
re.h
src/re.h
+1
-1
reporter.cc
src/reporter.cc
+1
-1
statistics.cc
src/statistics.cc
+4
-4
sysinfo.cc
src/sysinfo.cc
+1
-1
thread_timer.h
src/thread_timer.h
+4
-4
timers.cc
src/timers.cc
+2
-2
benchmark_random_interleaving_gtest.cc
test/benchmark_random_interleaving_gtest.cc
+3
-3
output_test.h
test/output_test.h
+4
-4
output_test_helper.cc
test/output_test_helper.cc
+16
-16
perf_counters_gtest.cc
test/perf_counters_gtest.cc
+3
-3
register_benchmark_test.cc
test/register_benchmark_test.cc
+3
-3
skip_with_error_test.cc
test/skip_with_error_test.cc
+5
-5
No files found.
src/benchmark.cc
View file @
6a5bf081
...
...
@@ -58,71 +58,71 @@
namespace
benchmark
{
// Print a list of benchmarks. This option overrides all other options.
DEFINE_bool
(
benchmark_list_tests
,
false
);
BM_
DEFINE_bool
(
benchmark_list_tests
,
false
);
// A regular expression that specifies the set of benchmarks to execute. If
// this flag is empty, or if this flag is the string \"all\", all benchmarks
// linked into the binary are run.
DEFINE_string
(
benchmark_filter
,
"."
);
BM_
DEFINE_string
(
benchmark_filter
,
"."
);
// Minimum number of seconds we should run benchmark before results are
// considered significant. For cpu-time based tests, this is the lower bound
// on the total cpu time used by all threads that make up the test. For
// real-time based tests, this is the lower bound on the elapsed time of the
// benchmark execution, regardless of number of threads.
DEFINE_double
(
benchmark_min_time
,
0.5
);
BM_
DEFINE_double
(
benchmark_min_time
,
0.5
);
// The number of runs of each benchmark. If greater than 1, the mean and
// standard deviation of the runs will be reported.
DEFINE_int32
(
benchmark_repetitions
,
1
);
BM_
DEFINE_int32
(
benchmark_repetitions
,
1
);
// If set, enable random interleaving of repetitions of all benchmarks.
// See http://github.com/google/benchmark/issues/1051 for details.
DEFINE_bool
(
benchmark_enable_random_interleaving
,
false
);
BM_
DEFINE_bool
(
benchmark_enable_random_interleaving
,
false
);
// Report the result of each benchmark repetitions. When 'true' is specified
// only the mean, standard deviation, and other statistics are reported for
// repeated benchmarks. Affects all reporters.
DEFINE_bool
(
benchmark_report_aggregates_only
,
false
);
BM_
DEFINE_bool
(
benchmark_report_aggregates_only
,
false
);
// Display the result of each benchmark repetitions. When 'true' is specified
// only the mean, standard deviation, and other statistics are displayed for
// repeated benchmarks. Unlike benchmark_report_aggregates_only, only affects
// the display reporter, but *NOT* file reporter, which will still contain
// all the output.
DEFINE_bool
(
benchmark_display_aggregates_only
,
false
);
BM_
DEFINE_bool
(
benchmark_display_aggregates_only
,
false
);
// The format to use for console output.
// Valid values are 'console', 'json', or 'csv'.
DEFINE_string
(
benchmark_format
,
"console"
);
BM_
DEFINE_string
(
benchmark_format
,
"console"
);
// The format to use for file output.
// Valid values are 'console', 'json', or 'csv'.
DEFINE_string
(
benchmark_out_format
,
"json"
);
BM_
DEFINE_string
(
benchmark_out_format
,
"json"
);
// The file to write additional output to.
DEFINE_string
(
benchmark_out
,
""
);
BM_
DEFINE_string
(
benchmark_out
,
""
);
// Whether to use colors in the output. Valid values:
// 'true'/'yes'/1, 'false'/'no'/0, and 'auto'. 'auto' means to use colors if
// the output is being sent to a terminal and the TERM environment variable is
// set to a terminal type that supports colors.
DEFINE_string
(
benchmark_color
,
"auto"
);
BM_
DEFINE_string
(
benchmark_color
,
"auto"
);
// Whether to use tabular format when printing user counters to the console.
// Valid values: 'true'/'yes'/1, 'false'/'no'/0. Defaults to false.
DEFINE_bool
(
benchmark_counters_tabular
,
false
);
BM_
DEFINE_bool
(
benchmark_counters_tabular
,
false
);
// List of additional perf counters to collect, in libpfm format. For more
// information about libpfm: https://man7.org/linux/man-pages/man3/libpfm.3.html
DEFINE_string
(
benchmark_perf_counters
,
""
);
BM_
DEFINE_string
(
benchmark_perf_counters
,
""
);
// Extra context to include in the output formatted as comma-separated key-value
// pairs. Kept internal as it's only used for parsing from env/command line.
DEFINE_kvpairs
(
benchmark_context
,
{});
BM_
DEFINE_kvpairs
(
benchmark_context
,
{});
// The level of verbose logging to output
DEFINE_int32
(
v
,
0
);
BM_
DEFINE_int32
(
v
,
0
);
namespace
internal
{
...
...
@@ -151,8 +151,9 @@ State::State(IterationCount max_iters, const std::vector<int64_t>& ranges,
timer_
(
timer
),
manager_
(
manager
),
perf_counters_measurement_
(
perf_counters_measurement
)
{
CHECK
(
max_iterations
!=
0
)
<<
"At least one iteration must be run"
;
CHECK_LT
(
thread_index
,
threads
)
<<
"thread_index must be less than threads"
;
BM_CHECK
(
max_iterations
!=
0
)
<<
"At least one iteration must be run"
;
BM_CHECK_LT
(
thread_index
,
threads
)
<<
"thread_index must be less than threads"
;
// Note: The use of offsetof below is technically undefined until C++17
// because State is not a standard layout type. However, all compilers
...
...
@@ -181,21 +182,21 @@ State::State(IterationCount max_iters, const std::vector<int64_t>& ranges,
void
State
::
PauseTiming
()
{
// Add in time accumulated so far
CHECK
(
started_
&&
!
finished_
&&
!
error_occurred_
);
BM_
CHECK
(
started_
&&
!
finished_
&&
!
error_occurred_
);
timer_
->
StopTimer
();
if
(
perf_counters_measurement_
)
{
auto
measurements
=
perf_counters_measurement_
->
StopAndGetMeasurements
();
for
(
const
auto
&
name_and_measurement
:
measurements
)
{
auto
name
=
name_and_measurement
.
first
;
auto
measurement
=
name_and_measurement
.
second
;
CHECK_EQ
(
counters
[
name
],
0.0
);
BM_
CHECK_EQ
(
counters
[
name
],
0.0
);
counters
[
name
]
=
Counter
(
measurement
,
Counter
::
kAvgIterations
);
}
}
}
void
State
::
ResumeTiming
()
{
CHECK
(
started_
&&
!
finished_
&&
!
error_occurred_
);
BM_
CHECK
(
started_
&&
!
finished_
&&
!
error_occurred_
);
timer_
->
StartTimer
();
if
(
perf_counters_measurement_
)
{
perf_counters_measurement_
->
Start
();
...
...
@@ -203,7 +204,7 @@ void State::ResumeTiming() {
}
void
State
::
SkipWithError
(
const
char
*
msg
)
{
CHECK
(
msg
);
BM_
CHECK
(
msg
);
error_occurred_
=
true
;
{
MutexLock
l
(
manager_
->
GetBenchmarkMutex
());
...
...
@@ -226,7 +227,7 @@ void State::SetLabel(const char* label) {
}
void
State
::
StartKeepRunning
()
{
CHECK
(
!
started_
&&
!
finished_
);
BM_
CHECK
(
!
started_
&&
!
finished_
);
started_
=
true
;
total_iterations_
=
error_occurred_
?
0
:
max_iterations
;
manager_
->
StartStopBarrier
();
...
...
@@ -234,7 +235,7 @@ void State::StartKeepRunning() {
}
void
State
::
FinishKeepRunning
()
{
CHECK
(
started_
&&
(
!
finished_
||
error_occurred_
));
BM_
CHECK
(
started_
&&
(
!
finished_
||
error_occurred_
));
if
(
!
error_occurred_
)
{
PauseTiming
();
}
...
...
@@ -282,7 +283,7 @@ void RunBenchmarks(const std::vector<BenchmarkInstance>& benchmarks,
BenchmarkReporter
*
display_reporter
,
BenchmarkReporter
*
file_reporter
)
{
// Note the file_reporter can be null.
CHECK
(
display_reporter
!=
nullptr
);
BM_
CHECK
(
display_reporter
!=
nullptr
);
// Determine the width of the name field using a minimum width of 10.
bool
might_have_aggregates
=
FLAGS_benchmark_repetitions
>
1
;
...
...
src/benchmark_register.cc
View file @
6a5bf081
...
...
@@ -111,7 +111,7 @@ void BenchmarkFamilies::ClearBenchmarks() {
bool
BenchmarkFamilies
::
FindBenchmarks
(
std
::
string
spec
,
std
::
vector
<
BenchmarkInstance
>*
benchmarks
,
std
::
ostream
*
ErrStream
)
{
CHECK
(
ErrStream
);
BM_
CHECK
(
ErrStream
);
auto
&
Err
=
*
ErrStream
;
// Make regular expression out of command-line flag
std
::
string
error_msg
;
...
...
@@ -225,7 +225,7 @@ Benchmark* Benchmark::Name(const std::string& name) {
}
Benchmark
*
Benchmark
::
Arg
(
int64_t
x
)
{
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
1
);
BM_
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
1
);
args_
.
push_back
({
x
});
return
this
;
}
...
...
@@ -236,7 +236,7 @@ Benchmark* Benchmark::Unit(TimeUnit unit) {
}
Benchmark
*
Benchmark
::
Range
(
int64_t
start
,
int64_t
limit
)
{
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
1
);
BM_
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
1
);
std
::
vector
<
int64_t
>
arglist
;
AddRange
(
&
arglist
,
start
,
limit
,
range_multiplier_
);
...
...
@@ -248,7 +248,7 @@ Benchmark* Benchmark::Range(int64_t start, int64_t limit) {
Benchmark
*
Benchmark
::
Ranges
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
int64_t
>>&
ranges
)
{
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
static_cast
<
int
>
(
ranges
.
size
()));
BM_
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
static_cast
<
int
>
(
ranges
.
size
()));
std
::
vector
<
std
::
vector
<
int64_t
>>
arglists
(
ranges
.
size
());
for
(
std
::
size_t
i
=
0
;
i
<
ranges
.
size
();
i
++
)
{
AddRange
(
&
arglists
[
i
],
ranges
[
i
].
first
,
ranges
[
i
].
second
,
...
...
@@ -262,7 +262,7 @@ Benchmark* Benchmark::Ranges(
Benchmark
*
Benchmark
::
ArgsProduct
(
const
std
::
vector
<
std
::
vector
<
int64_t
>>&
arglists
)
{
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
static_cast
<
int
>
(
arglists
.
size
()));
BM_
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
static_cast
<
int
>
(
arglists
.
size
()));
std
::
vector
<
std
::
size_t
>
indices
(
arglists
.
size
());
const
std
::
size_t
total
=
std
::
accumulate
(
...
...
@@ -289,20 +289,20 @@ Benchmark* Benchmark::ArgsProduct(
}
Benchmark
*
Benchmark
::
ArgName
(
const
std
::
string
&
name
)
{
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
1
);
BM_
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
1
);
arg_names_
=
{
name
};
return
this
;
}
Benchmark
*
Benchmark
::
ArgNames
(
const
std
::
vector
<
std
::
string
>&
names
)
{
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
static_cast
<
int
>
(
names
.
size
()));
BM_
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
static_cast
<
int
>
(
names
.
size
()));
arg_names_
=
names
;
return
this
;
}
Benchmark
*
Benchmark
::
DenseRange
(
int64_t
start
,
int64_t
limit
,
int
step
)
{
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
1
);
CHECK_LE
(
start
,
limit
);
BM_
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
1
);
BM_
CHECK_LE
(
start
,
limit
);
for
(
int64_t
arg
=
start
;
arg
<=
limit
;
arg
+=
step
)
{
args_
.
push_back
({
arg
});
}
...
...
@@ -310,7 +310,7 @@ Benchmark* Benchmark::DenseRange(int64_t start, int64_t limit, int step) {
}
Benchmark
*
Benchmark
::
Args
(
const
std
::
vector
<
int64_t
>&
args
)
{
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
static_cast
<
int
>
(
args
.
size
()));
BM_
CHECK
(
ArgsCnt
()
==
-
1
||
ArgsCnt
()
==
static_cast
<
int
>
(
args
.
size
()));
args_
.
push_back
(
args
);
return
this
;
}
...
...
@@ -321,27 +321,27 @@ Benchmark* Benchmark::Apply(void (*custom_arguments)(Benchmark* benchmark)) {
}
Benchmark
*
Benchmark
::
RangeMultiplier
(
int
multiplier
)
{
CHECK
(
multiplier
>
1
);
BM_
CHECK
(
multiplier
>
1
);
range_multiplier_
=
multiplier
;
return
this
;
}
Benchmark
*
Benchmark
::
MinTime
(
double
t
)
{
CHECK
(
t
>
0.0
);
CHECK
(
iterations_
==
0
);
BM_
CHECK
(
t
>
0.0
);
BM_
CHECK
(
iterations_
==
0
);
min_time_
=
t
;
return
this
;
}
Benchmark
*
Benchmark
::
Iterations
(
IterationCount
n
)
{
CHECK
(
n
>
0
);
CHECK
(
IsZero
(
min_time_
));
BM_
CHECK
(
n
>
0
);
BM_
CHECK
(
IsZero
(
min_time_
));
iterations_
=
n
;
return
this
;
}
Benchmark
*
Benchmark
::
Repetitions
(
int
n
)
{
CHECK
(
n
>
0
);
BM_
CHECK
(
n
>
0
);
repetitions_
=
n
;
return
this
;
}
...
...
@@ -374,14 +374,14 @@ Benchmark* Benchmark::MeasureProcessCPUTime() {
}
Benchmark
*
Benchmark
::
UseRealTime
()
{
CHECK
(
!
use_manual_time_
)
BM_
CHECK
(
!
use_manual_time_
)
<<
"Cannot set UseRealTime and UseManualTime simultaneously."
;
use_real_time_
=
true
;
return
this
;
}
Benchmark
*
Benchmark
::
UseManualTime
()
{
CHECK
(
!
use_real_time_
)
BM_
CHECK
(
!
use_real_time_
)
<<
"Cannot set UseRealTime and UseManualTime simultaneously."
;
use_manual_time_
=
true
;
return
this
;
...
...
@@ -405,14 +405,14 @@ Benchmark* Benchmark::ComputeStatistics(std::string name,
}
Benchmark
*
Benchmark
::
Threads
(
int
t
)
{
CHECK_GT
(
t
,
0
);
BM_
CHECK_GT
(
t
,
0
);
thread_counts_
.
push_back
(
t
);
return
this
;
}
Benchmark
*
Benchmark
::
ThreadRange
(
int
min_threads
,
int
max_threads
)
{
CHECK_GT
(
min_threads
,
0
);
CHECK_GE
(
max_threads
,
min_threads
);
BM_
CHECK_GT
(
min_threads
,
0
);
BM_
CHECK_GE
(
max_threads
,
min_threads
);
AddRange
(
&
thread_counts_
,
min_threads
,
max_threads
,
2
);
return
this
;
...
...
@@ -420,9 +420,9 @@ Benchmark* Benchmark::ThreadRange(int min_threads, int max_threads) {
Benchmark
*
Benchmark
::
DenseThreadRange
(
int
min_threads
,
int
max_threads
,
int
stride
)
{
CHECK_GT
(
min_threads
,
0
);
CHECK_GE
(
max_threads
,
min_threads
);
CHECK_GE
(
stride
,
1
);
BM_
CHECK_GT
(
min_threads
,
0
);
BM_
CHECK_GE
(
max_threads
,
min_threads
);
BM_
CHECK_GE
(
stride
,
1
);
for
(
auto
i
=
min_threads
;
i
<
max_threads
;
i
+=
stride
)
{
thread_counts_
.
push_back
(
i
);
...
...
@@ -466,7 +466,7 @@ std::vector<int64_t> CreateRange(int64_t lo, int64_t hi, int multi) {
std
::
vector
<
int64_t
>
CreateDenseRange
(
int64_t
start
,
int64_t
limit
,
int
step
)
{
CHECK_LE
(
start
,
limit
);
BM_
CHECK_LE
(
start
,
limit
);
std
::
vector
<
int64_t
>
args
;
for
(
int64_t
arg
=
start
;
arg
<=
limit
;
arg
+=
step
)
{
args
.
push_back
(
arg
);
...
...
src/benchmark_register.h
View file @
6a5bf081
...
...
@@ -14,9 +14,9 @@ namespace internal {
template
<
typename
T
>
typename
std
::
vector
<
T
>::
iterator
AddPowers
(
std
::
vector
<
T
>*
dst
,
T
lo
,
T
hi
,
int
mult
)
{
CHECK_GE
(
lo
,
0
);
CHECK_GE
(
hi
,
lo
);
CHECK_GE
(
mult
,
2
);
BM_
CHECK_GE
(
lo
,
0
);
BM_
CHECK_GE
(
hi
,
lo
);
BM_
CHECK_GE
(
mult
,
2
);
const
size_t
start_offset
=
dst
->
size
();
...
...
@@ -38,10 +38,10 @@ AddPowers(std::vector<T>* dst, T lo, T hi, int mult) {
template
<
typename
T
>
void
AddNegatedPowers
(
std
::
vector
<
T
>*
dst
,
T
lo
,
T
hi
,
int
mult
)
{
// We negate lo and hi so we require that they cannot be equal to 'min'.
CHECK_GT
(
lo
,
std
::
numeric_limits
<
T
>::
min
());
CHECK_GT
(
hi
,
std
::
numeric_limits
<
T
>::
min
());
CHECK_GE
(
hi
,
lo
);
CHECK_LE
(
hi
,
0
);
BM_
CHECK_GT
(
lo
,
std
::
numeric_limits
<
T
>::
min
());
BM_
CHECK_GT
(
hi
,
std
::
numeric_limits
<
T
>::
min
());
BM_
CHECK_GE
(
hi
,
lo
);
BM_
CHECK_LE
(
hi
,
0
);
// Add positive powers, then negate and reverse.
// Casts necessary since small integers get promoted
...
...
@@ -60,8 +60,8 @@ void AddRange(std::vector<T>* dst, T lo, T hi, int mult) {
static_assert
(
std
::
is_integral
<
T
>::
value
&&
std
::
is_signed
<
T
>::
value
,
"Args type must be a signed integer"
);
CHECK_GE
(
hi
,
lo
);
CHECK_GE
(
mult
,
2
);
BM_
CHECK_GE
(
hi
,
lo
);
BM_
CHECK_GE
(
mult
,
2
);
// Add "lo"
dst
->
push_back
(
lo
);
...
...
src/benchmark_runner.cc
View file @
6a5bf081
...
...
@@ -124,7 +124,7 @@ void RunInThread(const BenchmarkInstance* b, IterationCount iters,
:
internal
::
ThreadTimer
::
Create
());
State
st
=
b
->
Run
(
iters
,
thread_id
,
&
timer
,
manager
,
perf_counters_measurement
);
CHECK
(
st
.
error_occurred
()
||
st
.
iterations
()
>=
st
.
max_iterations
)
BM_
CHECK
(
st
.
error_occurred
()
||
st
.
iterations
()
>=
st
.
max_iterations
)
<<
"Benchmark returned before State::KeepRunning() returned false!"
;
{
MutexLock
l
(
manager
->
GetBenchmarkMutex
());
...
...
@@ -168,7 +168,7 @@ BenchmarkRunner::BenchmarkRunner(
internal
::
ARM_DisplayReportAggregatesOnly
);
run_results
.
file_report_aggregates_only
=
(
b
.
aggregation_report_mode
()
&
internal
::
ARM_FileReportAggregatesOnly
);
CHECK
(
FLAGS_benchmark_perf_counters
.
empty
()
||
BM_
CHECK
(
FLAGS_benchmark_perf_counters
.
empty
()
||
perf_counters_measurement
.
IsValid
())
<<
"Perf counters were requested but could not be set up."
;
}
...
...
src/benchmark_runner.h
View file @
6a5bf081
...
...
@@ -25,11 +25,11 @@
namespace
benchmark
{
DECLARE_double
(
benchmark_min_time
);
DECLARE_int32
(
benchmark_repetitions
);
DECLARE_bool
(
benchmark_report_aggregates_only
);
DECLARE_bool
(
benchmark_display_aggregates_only
);
DECLARE_string
(
benchmark_perf_counters
);
BM_
DECLARE_double
(
benchmark_min_time
);
BM_
DECLARE_int32
(
benchmark_repetitions
);
BM_
DECLARE_bool
(
benchmark_report_aggregates_only
);
BM_
DECLARE_bool
(
benchmark_display_aggregates_only
);
BM_
DECLARE_string
(
benchmark_perf_counters
);
namespace
internal
{
...
...
src/check.h
View file @
6a5bf081
...
...
@@ -23,8 +23,9 @@ BENCHMARK_NORETURN inline void CallAbortHandler() {
std
::
abort
();
// fallback to enforce noreturn
}
// CheckHandler is the class constructed by failing CHECK macros. CheckHandler
// will log information about the failures and abort when it is destructed.
// CheckHandler is the class constructed by failing BM_CHECK macros.
// CheckHandler will log information about the failures and abort when it is
// destructed.
class
CheckHandler
{
public
:
CheckHandler
(
const
char
*
check
,
const
char
*
file
,
const
char
*
func
,
int
line
)
...
...
@@ -51,32 +52,32 @@ class CheckHandler {
}
// end namespace internal
}
// end namespace benchmark
// The
CHECK macro returns a std::ostream object that can have extra information
// written to it.
// The
BM_CHECK macro returns a std::ostream object that can have extra
//
information
written to it.
#ifndef NDEBUG
#define
CHECK(b)
\
#define
BM_CHECK(b)
\
(b ? ::benchmark::internal::GetNullLogInstance() \
: ::benchmark::internal::CheckHandler(#b, __FILE__, __func__, __LINE__) \
.GetLog())
#else
#define CHECK(b) ::benchmark::internal::GetNullLogInstance()
#define
BM_
CHECK(b) ::benchmark::internal::GetNullLogInstance()
#endif
// clang-format off
// preserve whitespacing between operators for alignment
#define
CHECK_EQ(a, b)
CHECK((a) == (b))
#define
CHECK_NE(a, b)
CHECK((a) != (b))
#define
CHECK_GE(a, b)
CHECK((a) >= (b))
#define
CHECK_LE(a, b)
CHECK((a) <= (b))
#define
CHECK_GT(a, b)
CHECK((a) > (b))
#define
CHECK_LT(a, b)
CHECK((a) < (b))
#define
CHECK_FLOAT_EQ(a, b, eps)
CHECK(std::fabs((a) - (b)) < (eps))
#define
CHECK_FLOAT_NE(a, b, eps)
CHECK(std::fabs((a) - (b)) >= (eps))
#define
CHECK_FLOAT_GE(a, b, eps)
CHECK((a) - (b) > -(eps))
#define
CHECK_FLOAT_LE(a, b, eps)
CHECK((b) - (a) > -(eps))
#define
CHECK_FLOAT_GT(a, b, eps)
CHECK((a) - (b) > (eps))
#define
CHECK_FLOAT_LT(a, b, eps)
CHECK((b) - (a) > (eps))
#define
BM_CHECK_EQ(a, b) BM_
CHECK((a) == (b))
#define
BM_CHECK_NE(a, b) BM_
CHECK((a) != (b))
#define
BM_CHECK_GE(a, b) BM_
CHECK((a) >= (b))
#define
BM_CHECK_LE(a, b) BM_
CHECK((a) <= (b))
#define
BM_CHECK_GT(a, b) BM_
CHECK((a) > (b))
#define
BM_CHECK_LT(a, b) BM_
CHECK((a) < (b))
#define
BM_CHECK_FLOAT_EQ(a, b, eps) BM_
CHECK(std::fabs((a) - (b)) < (eps))
#define
BM_CHECK_FLOAT_NE(a, b, eps) BM_
CHECK(std::fabs((a) - (b)) >= (eps))
#define
BM_CHECK_FLOAT_GE(a, b, eps) BM_
CHECK((a) - (b) > -(eps))
#define
BM_CHECK_FLOAT_LE(a, b, eps) BM_
CHECK((b) - (a) > -(eps))
#define
BM_CHECK_FLOAT_GT(a, b, eps) BM_
CHECK((a) - (b) > (eps))
#define
BM_CHECK_FLOAT_LT(a, b, eps) BM_
CHECK((b) - (a) > (eps))
//clang-format on
#endif // CHECK_H_
src/colorprint.cc
View file @
6a5bf081
...
...
@@ -94,7 +94,7 @@ std::string FormatString(const char* msg, va_list args) {
va_end
(
args_cp
);
// currently there is no error handling for failure, so this is hack.
CHECK
(
ret
>=
0
);
BM_
CHECK
(
ret
>=
0
);
if
(
ret
==
0
)
// handle empty expansion
return
{};
...
...
@@ -105,7 +105,7 @@ std::string FormatString(const char* msg, va_list args) {
size
=
(
size_t
)
ret
+
1
;
// + 1 for the null byte
std
::
unique_ptr
<
char
[]
>
buff
(
new
char
[
size
]);
ret
=
vsnprintf
(
buff
.
get
(),
size
,
msg
,
args
);
CHECK
(
ret
>
0
&&
((
size_t
)
ret
)
<
size
);
BM_
CHECK
(
ret
>
0
&&
((
size_t
)
ret
)
<
size
);
return
buff
.
get
();
}
}
...
...
src/commandlineflags.h
View file @
6a5bf081
...
...
@@ -9,23 +9,23 @@
#define FLAG(name) FLAGS_##name
// Macros for declaring flags.
#define DECLARE_bool(name) extern bool FLAG(name)
#define DECLARE_int32(name) extern int32_t FLAG(name)
#define DECLARE_double(name) extern double FLAG(name)
#define DECLARE_string(name) extern std::string FLAG(name)
#define DECLARE_kvpairs(name) \
#define
BM_
DECLARE_bool(name) extern bool FLAG(name)
#define
BM_
DECLARE_int32(name) extern int32_t FLAG(name)
#define
BM_
DECLARE_double(name) extern double FLAG(name)
#define
BM_
DECLARE_string(name) extern std::string FLAG(name)
#define
BM_
DECLARE_kvpairs(name) \
extern std::map<std::string, std::string> FLAG(name)
// Macros for defining flags.
#define DEFINE_bool(name, default_val) \
#define
BM_
DEFINE_bool(name, default_val) \
bool FLAG(name) = benchmark::BoolFromEnv(#name, default_val)
#define DEFINE_int32(name, default_val) \
#define
BM_
DEFINE_int32(name, default_val) \
int32_t FLAG(name) = benchmark::Int32FromEnv(#name, default_val)
#define DEFINE_double(name, default_val) \
#define
BM_
DEFINE_double(name, default_val) \
double FLAG(name) = benchmark::DoubleFromEnv(#name, default_val)
#define DEFINE_string(name, default_val) \
#define
BM_
DEFINE_string(name, default_val) \
std::string FLAG(name) = benchmark::StringFromEnv(#name, default_val)
#define
DEFINE_kvpairs(name, default_val)
\
#define
BM_DEFINE_kvpairs(name, default_val)
\
std::map<std::string, std::string> FLAG(name) = \
benchmark::KvPairsFromEnv(#name, default_val)
...
...
src/complexity.cc
View file @
6a5bf081
...
...
@@ -123,10 +123,10 @@ LeastSq MinimalLeastSq(const std::vector<int64_t>& n,
// fitting curve.
LeastSq
MinimalLeastSq
(
const
std
::
vector
<
int64_t
>&
n
,
const
std
::
vector
<
double
>&
time
,
const
BigO
complexity
)
{
CHECK_EQ
(
n
.
size
(),
time
.
size
());
CHECK_GE
(
n
.
size
(),
2
);
// Do not compute fitting curve is less than two
BM_
CHECK_EQ
(
n
.
size
(),
time
.
size
());
BM_
CHECK_GE
(
n
.
size
(),
2
);
// Do not compute fitting curve is less than two
// benchmark runs are given
CHECK_NE
(
complexity
,
oNone
);
BM_
CHECK_NE
(
complexity
,
oNone
);
LeastSq
best_fit
;
...
...
@@ -167,7 +167,8 @@ std::vector<BenchmarkReporter::Run> ComputeBigO(
// Populate the accumulators.
for
(
const
Run
&
run
:
reports
)
{
CHECK_GT
(
run
.
complexity_n
,
0
)
<<
"Did you forget to call SetComplexityN?"
;
BM_CHECK_GT
(
run
.
complexity_n
,
0
)
<<
"Did you forget to call SetComplexityN?"
;
n
.
push_back
(
run
.
complexity_n
);
real_time
.
push_back
(
run
.
real_accumulated_time
/
run
.
iterations
);
cpu_time
.
push_back
(
run
.
cpu_accumulated_time
/
run
.
iterations
);
...
...
src/csv_reporter.cc
View file @
6a5bf081
...
...
@@ -85,7 +85,8 @@ void CSVReporter::ReportRuns(const std::vector<Run>& reports) {
for
(
const
auto
&
cnt
:
run
.
counters
)
{
if
(
cnt
.
first
==
"bytes_per_second"
||
cnt
.
first
==
"items_per_second"
)
continue
;
CHECK
(
user_counter_names_
.
find
(
cnt
.
first
)
!=
user_counter_names_
.
end
())
BM_CHECK
(
user_counter_names_
.
find
(
cnt
.
first
)
!=
user_counter_names_
.
end
())
<<
"All counters must be present in each run. "
<<
"Counter named
\"
"
<<
cnt
.
first
<<
"
\"
was not in a run after being added to the header"
;
...
...
src/mutex.h
View file @
6a5bf081
...
...
@@ -130,7 +130,7 @@ class Barrier {
// entered the barrier. Returns iff this is the last thread to
// enter the barrier.
bool
createBarrier
(
MutexLock
&
ml
)
REQUIRES
(
lock_
)
{
CHECK_LT
(
entered_
,
running_threads_
);
BM_
CHECK_LT
(
entered_
,
running_threads_
);
entered_
++
;
if
(
entered_
<
running_threads_
)
{
// Wait for all threads to enter
...
...
src/perf_counters.h
View file @
6a5bf081
...
...
@@ -42,7 +42,7 @@ namespace internal {
class
PerfCounterValues
{
public
:
explicit
PerfCounterValues
(
size_t
nr_counters
)
:
nr_counters_
(
nr_counters
)
{
CHECK_LE
(
nr_counters_
,
kMaxCounters
);
BM_
CHECK_LE
(
nr_counters_
,
kMaxCounters
);
}
uint64_t
operator
[](
size_t
pos
)
const
{
return
values_
[
kPadding
+
pos
];
}
...
...
src/re.h
View file @
6a5bf081
...
...
@@ -126,7 +126,7 @@ inline bool Regex::Init(const std::string& spec, std::string* error) {
// regerror returns the number of bytes necessary to null terminate
// the string, so we move that when assigning to error.
CHECK_NE
(
needed
,
0
);
BM_
CHECK_NE
(
needed
,
0
);
error
->
assign
(
errbuf
,
needed
-
1
);
delete
[]
errbuf
;
...
...
src/reporter.cc
View file @
6a5bf081
...
...
@@ -38,7 +38,7 @@ BenchmarkReporter::~BenchmarkReporter() {}
void
BenchmarkReporter
::
PrintBasicContext
(
std
::
ostream
*
out
,
Context
const
&
context
)
{
CHECK
(
out
)
<<
"cannot be null"
;
BM_
CHECK
(
out
)
<<
"cannot be null"
;
auto
&
Out
=
*
out
;
Out
<<
LocalDateTimeString
()
<<
"
\n
"
;
...
...
src/statistics.cc
View file @
6a5bf081
...
...
@@ -112,22 +112,22 @@ std::vector<BenchmarkReporter::Run> ComputeStats(
it
=
counter_stats
.
find
(
cnt
.
first
);
it
->
second
.
s
.
reserve
(
reports
.
size
());
}
else
{
CHECK_EQ
(
counter_stats
[
cnt
.
first
].
c
.
flags
,
cnt
.
second
.
flags
);
BM_
CHECK_EQ
(
counter_stats
[
cnt
.
first
].
c
.
flags
,
cnt
.
second
.
flags
);
}
}
}
// Populate the accumulators.
for
(
Run
const
&
run
:
reports
)
{
CHECK_EQ
(
reports
[
0
].
benchmark_name
(),
run
.
benchmark_name
());
CHECK_EQ
(
run_iterations
,
run
.
iterations
);
BM_
CHECK_EQ
(
reports
[
0
].
benchmark_name
(),
run
.
benchmark_name
());
BM_
CHECK_EQ
(
run_iterations
,
run
.
iterations
);
if
(
run
.
error_occurred
)
continue
;
real_accumulated_time_stat
.
emplace_back
(
run
.
real_accumulated_time
);
cpu_accumulated_time_stat
.
emplace_back
(
run
.
cpu_accumulated_time
);
// user counters
for
(
auto
const
&
cnt
:
run
.
counters
)
{
auto
it
=
counter_stats
.
find
(
cnt
.
first
);
CHECK_NE
(
it
,
counter_stats
.
end
());
BM_
CHECK_NE
(
it
,
counter_stats
.
end
());
it
->
second
.
s
.
emplace_back
(
cnt
.
second
);
}
}
...
...
src/sysinfo.cc
View file @
6a5bf081
...
...
@@ -135,7 +135,7 @@ struct ValueUnion {
template
<
class
T
,
int
N
>
std
::
array
<
T
,
N
>
GetAsArray
()
{
const
int
ArrSize
=
sizeof
(
T
)
*
N
;
CHECK_LE
(
ArrSize
,
Size
);
BM_
CHECK_LE
(
ArrSize
,
Size
);
std
::
array
<
T
,
N
>
Arr
;
std
::
memcpy
(
Arr
.
data
(),
data
(),
ArrSize
);
return
Arr
;
...
...
src/thread_timer.h
View file @
6a5bf081
...
...
@@ -28,7 +28,7 @@ class ThreadTimer {
// Called by each thread
void
StopTimer
()
{
CHECK
(
running_
);
BM_
CHECK
(
running_
);
running_
=
false
;
real_time_used_
+=
ChronoClockNow
()
-
start_real_time_
;
// Floating point error can result in the subtraction producing a negative
...
...
@@ -44,19 +44,19 @@ class ThreadTimer {
// REQUIRES: timer is not running
double
real_time_used
()
const
{
CHECK
(
!
running_
);
BM_
CHECK
(
!
running_
);
return
real_time_used_
;
}
// REQUIRES: timer is not running
double
cpu_time_used
()
const
{
CHECK
(
!
running_
);
BM_
CHECK
(
!
running_
);
return
cpu_time_used_
;
}
// REQUIRES: timer is not running
double
manual_time_used
()
const
{
CHECK
(
!
running_
);
BM_
CHECK
(
!
running_
);
return
manual_time_used_
;
}
...
...
src/timers.cc
View file @
6a5bf081
...
...
@@ -225,7 +225,7 @@ std::string LocalDateTimeString() {
tz_len
=
::
snprintf
(
tz_offset
,
sizeof
(
tz_offset
),
"%c%02li:%02li"
,
tz_offset_sign
,
offset_minutes
/
100
,
offset_minutes
%
100
);
CHECK
(
tz_len
==
kTzOffsetLen
);
BM_
CHECK
(
tz_len
==
kTzOffsetLen
);
((
void
)
tz_len
);
// Prevent unused variable warning in optimized build.
}
else
{
// Unknown offset. RFC3339 specifies that unknown local offsets should be
...
...
@@ -242,7 +242,7 @@ std::string LocalDateTimeString() {
timestamp_len
=
std
::
strftime
(
storage
,
sizeof
(
storage
),
"%Y-%m-%dT%H:%M:%S"
,
timeinfo_p
);
CHECK
(
timestamp_len
==
kTimestampLen
);
BM_
CHECK
(
timestamp_len
==
kTimestampLen
);
// Prevent unused variable warning in optimized build.
((
void
)
kTimestampLen
);
...
...
test/benchmark_random_interleaving_gtest.cc
View file @
6a5bf081
...
...
@@ -10,9 +10,9 @@
namespace
benchmark
{
DECLARE_bool
(
benchmark_enable_random_interleaving
);
DECLARE_string
(
benchmark_filter
);
DECLARE_int32
(
benchmark_repetitions
);
BM_
DECLARE_bool
(
benchmark_enable_random_interleaving
);
BM_
DECLARE_string
(
benchmark_filter
);
BM_
DECLARE_int32
(
benchmark_repetitions
);
namespace
internal
{
namespace
{
...
...
test/output_test.h
View file @
6a5bf081
...
...
@@ -143,12 +143,12 @@ struct Results {
template
<
class
T
>
T
Results
::
GetAs
(
const
char
*
entry_name
)
const
{
auto
*
sv
=
Get
(
entry_name
);
CHECK
(
sv
!=
nullptr
&&
!
sv
->
empty
());
BM_
CHECK
(
sv
!=
nullptr
&&
!
sv
->
empty
());
std
::
stringstream
ss
;
ss
<<
*
sv
;
T
out
;
ss
>>
out
;
CHECK
(
!
ss
.
fail
());
BM_
CHECK
(
!
ss
.
fail
());
return
out
;
}
...
...
@@ -159,7 +159,7 @@ T Results::GetAs(const char* entry_name) const {
// clang-format off
#define CHECK_RESULT_VALUE_IMPL(entry, getfn, var_type, var_name, relationship, value) \
CONCAT(CHECK_, relationship) \
CONCAT(
BM_
CHECK_, relationship) \
(entry.getfn< var_type >(var_name), (value)) << "\n" \
<< __FILE__ << ":" << __LINE__ << ": " << (entry).name << ":\n" \
<< __FILE__ << ":" << __LINE__ << ": " \
...
...
@@ -170,7 +170,7 @@ T Results::GetAs(const char* entry_name) const {
// check with tolerance. eps_factor is the tolerance window, which is
// interpreted relative to value (eg, 0.1 means 10% of value).
#define CHECK_FLOAT_RESULT_VALUE_IMPL(entry, getfn, var_type, var_name, relationship, value, eps_factor) \
CONCAT(CHECK_FLOAT_, relationship) \
CONCAT(
BM_
CHECK_FLOAT_, relationship) \
(entry.getfn< var_type >(var_name), (value), (eps_factor) * (value)) << "\n" \
<< __FILE__ << ":" << __LINE__ << ": " << (entry).name << ":\n" \
<< __FILE__ << ":" << __LINE__ << ": " \
...
...
test/output_test_helper.cc
View file @
6a5bf081
...
...
@@ -94,27 +94,27 @@ void CheckCase(std::stringstream& remaining_output, TestCase const& TC,
bool
on_first
=
true
;
std
::
string
line
;
while
(
remaining_output
.
eof
()
==
false
)
{
CHECK
(
remaining_output
.
good
());
BM_
CHECK
(
remaining_output
.
good
());
std
::
getline
(
remaining_output
,
line
);
if
(
on_first
)
{
first_line
=
line
;
on_first
=
false
;
}
for
(
const
auto
&
NC
:
not_checks
)
{
CHECK
(
!
NC
.
regex
->
Match
(
line
))
BM_
CHECK
(
!
NC
.
regex
->
Match
(
line
))
<<
"Unexpected match for line
\"
"
<<
line
<<
"
\"
for MR_Not regex
\"
"
<<
NC
.
regex_str
<<
"
\"
"
<<
"
\n
actual regex string
\"
"
<<
TC
.
substituted_regex
<<
"
\"
"
<<
"
\n
started matching near: "
<<
first_line
;
}
if
(
TC
.
regex
->
Match
(
line
))
return
;
CHECK
(
TC
.
match_rule
!=
MR_Next
)
BM_
CHECK
(
TC
.
match_rule
!=
MR_Next
)
<<
"Expected line
\"
"
<<
line
<<
"
\"
to match regex
\"
"
<<
TC
.
regex_str
<<
"
\"
"
<<
"
\n
actual regex string
\"
"
<<
TC
.
substituted_regex
<<
"
\"
"
<<
"
\n
started matching near: "
<<
first_line
;
}
CHECK
(
remaining_output
.
eof
()
==
false
)
BM_
CHECK
(
remaining_output
.
eof
()
==
false
)
<<
"End of output reached before match for regex
\"
"
<<
TC
.
regex_str
<<
"
\"
was found"
<<
"
\n
actual regex string
\"
"
<<
TC
.
substituted_regex
<<
"
\"
"
...
...
@@ -144,7 +144,7 @@ class TestReporter : public benchmark::BenchmarkReporter {
bool
first
=
true
;
for
(
auto
rep
:
reporters_
)
{
bool
new_ret
=
rep
->
ReportContext
(
context
);
CHECK
(
first
||
new_ret
==
last_ret
)
BM_
CHECK
(
first
||
new_ret
==
last_ret
)
<<
"Reports return different values for ReportContext"
;
first
=
false
;
last_ret
=
new_ret
;
...
...
@@ -226,7 +226,7 @@ void ResultsChecker::CheckResults(std::stringstream& output) {
std
::
string
line
;
bool
on_first
=
true
;
while
(
output
.
eof
()
==
false
)
{
CHECK
(
output
.
good
());
BM_
CHECK
(
output
.
good
());
std
::
getline
(
output
,
line
);
if
(
on_first
)
{
SetHeader_
(
line
);
// this is important
...
...
@@ -261,9 +261,9 @@ void ResultsChecker::SetHeader_(const std::string& csv_header) {
// set the values for a benchmark
void
ResultsChecker
::
SetValues_
(
const
std
::
string
&
entry_csv_line
)
{
if
(
entry_csv_line
.
empty
())
return
;
// some lines are empty
CHECK
(
!
field_names
.
empty
());
BM_
CHECK
(
!
field_names
.
empty
());
auto
vals
=
SplitCsv_
(
entry_csv_line
);
CHECK_EQ
(
vals
.
size
(),
field_names
.
size
());
BM_
CHECK_EQ
(
vals
.
size
(),
field_names
.
size
());
results
.
emplace_back
(
vals
[
0
]);
// vals[0] is the benchmark name
auto
&
entry
=
results
.
back
();
for
(
size_t
i
=
1
,
e
=
vals
.
size
();
i
<
e
;
++
i
)
{
...
...
@@ -278,7 +278,7 @@ std::vector<std::string> ResultsChecker::SplitCsv_(const std::string& line) {
if
(
!
field_names
.
empty
())
out
.
reserve
(
field_names
.
size
());
size_t
prev
=
0
,
pos
=
line
.
find_first_of
(
','
),
curr
=
pos
;
while
(
pos
!=
line
.
npos
)
{
CHECK
(
curr
>
0
);
BM_
CHECK
(
curr
>
0
);
if
(
line
[
prev
]
==
'"'
)
++
prev
;
if
(
line
[
curr
-
1
]
==
'"'
)
--
curr
;
out
.
push_back
(
line
.
substr
(
prev
,
curr
-
prev
));
...
...
@@ -309,7 +309,7 @@ int Results::NumThreads() const {
ss
<<
name
.
substr
(
pos
+
9
,
end
);
int
num
=
1
;
ss
>>
num
;
CHECK
(
!
ss
.
fail
());
BM_
CHECK
(
!
ss
.
fail
());
return
num
;
}
...
...
@@ -318,11 +318,11 @@ double Results::NumIterations() const {
}
double
Results
::
GetTime
(
BenchmarkTime
which
)
const
{
CHECK
(
which
==
kCpuTime
||
which
==
kRealTime
);
BM_
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
);
BM_
CHECK
(
unit
);
if
(
*
unit
==
"ns"
)
{
return
val
*
1.e-9
;
}
else
if
(
*
unit
==
"us"
)
{
...
...
@@ -332,7 +332,7 @@ double Results::GetTime(BenchmarkTime which) const {
}
else
if
(
*
unit
==
"s"
)
{
return
val
;
}
else
{
CHECK
(
1
==
0
)
<<
"unknown time unit: "
<<
*
unit
;
BM_
CHECK
(
1
==
0
)
<<
"unknown time unit: "
<<
*
unit
;
return
0
;
}
}
...
...
@@ -348,8 +348,8 @@ TestCase::TestCase(std::string re, int rule)
regex
(
std
::
make_shared
<
benchmark
::
Regex
>
())
{
std
::
string
err_str
;
regex
->
Init
(
substituted_regex
,
&
err_str
);
CHECK
(
err_str
.
empty
())
<<
"Could not construct regex
\"
"
<<
substituted_regex
<<
"
\"
"
BM_CHECK
(
err_str
.
empty
())
<<
"Could not construct regex
\"
"
<<
substituted_regex
<<
"
\"
"
<<
"
\n
originally
\"
"
<<
regex_str
<<
"
\"
"
<<
"
\n
got error: "
<<
err_str
;
}
...
...
@@ -438,7 +438,7 @@ void RunOutputTests(int argc, char* argv[]) {
// the checks to subscribees.
auto
&
csv
=
TestCases
[
2
];
// would use == but gcc spits a warning
CHECK
(
std
::
strcmp
(
csv
.
name
,
"CSVReporter"
)
==
0
);
BM_
CHECK
(
std
::
strcmp
(
csv
.
name
,
"CSVReporter"
)
==
0
);
internal
::
GetResultsChecker
().
CheckResults
(
csv
.
out_stream
);
}
...
...
test/perf_counters_gtest.cc
View file @
6a5bf081
...
...
@@ -103,10 +103,10 @@ size_t do_work() {
void
measure
(
size_t
threadcount
,
PerfCounterValues
*
values1
,
PerfCounterValues
*
values2
)
{
CHECK_NE
(
values1
,
nullptr
);
CHECK_NE
(
values2
,
nullptr
);
BM_
CHECK_NE
(
values1
,
nullptr
);
BM_
CHECK_NE
(
values2
,
nullptr
);
std
::
vector
<
std
::
thread
>
threads
(
threadcount
);
auto
work
=
[
&
]()
{
CHECK
(
do_work
()
>
1000
);
};
auto
work
=
[
&
]()
{
BM_
CHECK
(
do_work
()
>
1000
);
};
// We need to first set up the counters, then start the threads, so the
// threads would inherit the counters. But later, we need to first destroy the
...
...
test/register_benchmark_test.cc
View file @
6a5bf081
...
...
@@ -30,13 +30,13 @@ struct TestCase {
void
CheckRun
(
Run
const
&
run
)
const
{
// clang-format off
CHECK
(
name
==
run
.
benchmark_name
())
<<
"expected "
<<
name
<<
" got "
BM_
CHECK
(
name
==
run
.
benchmark_name
())
<<
"expected "
<<
name
<<
" got "
<<
run
.
benchmark_name
();
if
(
label
)
{
CHECK
(
run
.
report_label
==
label
)
<<
"expected "
<<
label
<<
" got "
BM_
CHECK
(
run
.
report_label
==
label
)
<<
"expected "
<<
label
<<
" got "
<<
run
.
report_label
;
}
else
{
CHECK
(
run
.
report_label
==
""
);
BM_
CHECK
(
run
.
report_label
==
""
);
}
// clang-format on
}
...
...
test/skip_with_error_test.cc
View file @
6a5bf081
...
...
@@ -33,14 +33,14 @@ struct TestCase {
typedef
benchmark
::
BenchmarkReporter
::
Run
Run
;
void
CheckRun
(
Run
const
&
run
)
const
{
CHECK
(
name
==
run
.
benchmark_name
())
BM_
CHECK
(
name
==
run
.
benchmark_name
())
<<
"expected "
<<
name
<<
" got "
<<
run
.
benchmark_name
();
CHECK
(
error_occurred
==
run
.
error_occurred
);
CHECK
(
error_message
==
run
.
error_message
);
BM_
CHECK
(
error_occurred
==
run
.
error_occurred
);
BM_
CHECK
(
error_message
==
run
.
error_message
);
if
(
error_occurred
)
{
// CHECK(run.iterations == 0);
//
BM_
CHECK(run.iterations == 0);
}
else
{
CHECK
(
run
.
iterations
!=
0
);
BM_
CHECK
(
run
.
iterations
!=
0
);
}
}
};
...
...
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