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
481e06e6
Commit
481e06e6
authored
May 23, 2016
by
Eric Fiselier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address review comments
parent
751e07d4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
7 deletions
+16
-7
benchmark_api.h
include/benchmark/benchmark_api.h
+2
-1
check.h
src/check.h
+4
-4
diagnostics_test.cc
test/diagnostics_test.cc
+10
-2
No files found.
include/benchmark/benchmark_api.h
View file @
481e06e6
...
@@ -235,7 +235,8 @@ enum TimeUnit {
...
@@ -235,7 +235,8 @@ enum TimeUnit {
// benchmark to use.
// benchmark to use.
class
State
{
class
State
{
public
:
public
:
State
(
size_t
max_iters
,
bool
has_x
,
int
x
,
bool
has_y
,
int
y
,
int
thread_i
,
int
n_threads
);
State
(
size_t
max_iters
,
bool
has_x
,
int
x
,
bool
has_y
,
int
y
,
int
thread_i
,
int
n_threads
);
// Returns true iff the benchmark should continue through another iteration.
// Returns true iff the benchmark should continue through another iteration.
// NOTE: A benchmark may not return from the test until KeepRunning() has
// NOTE: A benchmark may not return from the test until KeepRunning() has
...
...
src/check.h
View file @
481e06e6
...
@@ -12,13 +12,13 @@ namespace internal {
...
@@ -12,13 +12,13 @@ namespace internal {
typedef
void
(
AbortHandlerT
)();
typedef
void
(
AbortHandlerT
)();
inline
AbortHandlerT
*&
get_abort_h
andler
()
{
inline
AbortHandlerT
*&
GetAbortH
andler
()
{
static
AbortHandlerT
*
handler
=
&
std
::
abort
;
static
AbortHandlerT
*
handler
=
&
std
::
abort
;
return
handler
;
return
handler
;
}
}
BENCHMARK_NORETURN
inline
void
abort_h
andler
()
{
BENCHMARK_NORETURN
inline
void
CallAbortH
andler
()
{
get_abort_h
andler
()();
GetAbortH
andler
()();
std
::
abort
();
// fallback to enforce noreturn
std
::
abort
();
// fallback to enforce noreturn
}
}
...
@@ -39,7 +39,7 @@ public:
...
@@ -39,7 +39,7 @@ public:
BENCHMARK_NORETURN
~
CheckHandler
()
noexcept
(
false
)
{
BENCHMARK_NORETURN
~
CheckHandler
()
noexcept
(
false
)
{
log_
<<
std
::
endl
;
log_
<<
std
::
endl
;
abort_h
andler
();
CallAbortH
andler
();
}
}
CheckHandler
&
operator
=
(
const
CheckHandler
&
)
=
delete
;
CheckHandler
&
operator
=
(
const
CheckHandler
&
)
=
delete
;
...
...
test/diagnostics_test.cc
View file @
481e06e6
// Testing:
// State::PauseTiming()
// State::ResumeTiming()
// Test that CHECK's within these function diagnose when they are called
// outside of the KeepRunning() loop.
//
// NOTE: Users should NOT include or use src/check.h. This is only done in
// order to test library internals.
#include "benchmark/benchmark_api.h"
#include "benchmark/benchmark_api.h"
#include "../src/check.h"
#include "../src/check.h"
void
test_h
andler
()
{
void
TestH
andler
()
{
throw
std
::
logic_error
(
""
);
throw
std
::
logic_error
(
""
);
}
}
...
@@ -37,7 +45,7 @@ void BM_diagnostic_test(benchmark::State& state) {
...
@@ -37,7 +45,7 @@ void BM_diagnostic_test(benchmark::State& state) {
BENCHMARK
(
BM_diagnostic_test
);
BENCHMARK
(
BM_diagnostic_test
);
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
benchmark
::
internal
::
get_abort_handler
()
=
&
test_h
andler
;
benchmark
::
internal
::
GetAbortHandler
()
=
&
TestH
andler
;
benchmark
::
Initialize
(
&
argc
,
argv
);
benchmark
::
Initialize
(
&
argc
,
argv
);
benchmark
::
RunSpecifiedBenchmarks
();
benchmark
::
RunSpecifiedBenchmarks
();
}
}
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