mirror of https://github.com/google/benchmark.git
Address review comments
This commit is contained in:
parent
751e07d42d
commit
481e06e65a
|
@ -235,7 +235,8 @@ enum TimeUnit {
|
|||
// benchmark to use.
|
||||
class State {
|
||||
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.
|
||||
// NOTE: A benchmark may not return from the test until KeepRunning() has
|
||||
|
|
|
@ -12,13 +12,13 @@ namespace internal {
|
|||
|
||||
typedef void(AbortHandlerT)();
|
||||
|
||||
inline AbortHandlerT*& get_abort_handler() {
|
||||
inline AbortHandlerT*& GetAbortHandler() {
|
||||
static AbortHandlerT* handler = &std::abort;
|
||||
return handler;
|
||||
}
|
||||
|
||||
BENCHMARK_NORETURN inline void abort_handler() {
|
||||
get_abort_handler()();
|
||||
BENCHMARK_NORETURN inline void CallAbortHandler() {
|
||||
GetAbortHandler()();
|
||||
std::abort(); // fallback to enforce noreturn
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
BENCHMARK_NORETURN ~CheckHandler() noexcept(false) {
|
||||
log_ << std::endl;
|
||||
abort_handler();
|
||||
CallAbortHandler();
|
||||
}
|
||||
|
||||
CheckHandler & operator=(const CheckHandler&) = delete;
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
// 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 "../src/check.h"
|
||||
|
||||
void test_handler() {
|
||||
void TestHandler() {
|
||||
throw std::logic_error("");
|
||||
}
|
||||
|
||||
|
@ -37,7 +45,7 @@ void BM_diagnostic_test(benchmark::State& state) {
|
|||
BENCHMARK(BM_diagnostic_test);
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
benchmark::internal::get_abort_handler() = &test_handler;
|
||||
benchmark::internal::GetAbortHandler() = &TestHandler;
|
||||
benchmark::Initialize(&argc, argv);
|
||||
benchmark::RunSpecifiedBenchmarks();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue