Wire Sysio
Wire Sysion 1.0.0
Loading...
Searching...
No Matches
catch_benchmark.h
Go to the documentation of this file.
1
/*
2
* Created by Phil on 04/07/2017.
3
* Copyright 2017 Two Blue Cubes Ltd. All rights reserved.
4
*
5
* Distributed under the Boost Software License, Version 1.0. (See accompanying
6
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
*/
8
#ifndef TWOBLUECUBES_CATCH_BENCHMARK_H_INCLUDED
9
#define TWOBLUECUBES_CATCH_BENCHMARK_H_INCLUDED
10
11
#include "
catch_stringref.h
"
12
#include "
catch_timer.h
"
13
14
#include <cstdint>
15
#include <string>
16
17
namespace
Catch
{
18
19
class
BenchmarkLooper {
20
21
std::string m_name;
22
std::size_t m_count = 0;
23
std::size_t m_iterationsToRun = 1;
24
uint64_t
m_resolution;
25
Timer m_timer;
26
27
static
auto
getResolution() ->
uint64_t
;
28
public
:
29
// Keep most of this inline as it's on the code path that is being timed
30
BenchmarkLooper
(
StringRef
name
)
31
: m_name(
name
),
32
m_resolution( getResolution() )
33
{
34
reportStart
();
35
m_timer.start();
36
}
37
38
explicit
operator
bool() {
39
if
( m_count < m_iterationsToRun )
40
return
true
;
41
return
needsMoreIterations
();
42
}
43
44
void
increment
() {
45
++m_count;
46
}
47
48
void
reportStart
();
49
auto
needsMoreIterations
() -> bool;
50
};
51
52
}
// end namespace Catch
53
54
#define BENCHMARK( name ) \
55
for( Catch::BenchmarkLooper looper( name ); looper; looper.increment() )
56
57
#endif
// TWOBLUECUBES_CATCH_BENCHMARK_H_INCLUDED
name
std::string name
Definition
catch_reporter_console.cpp:186
catch_stringref.h
catch_timer.h
Catch::BenchmarkLooper::reportStart
void reportStart()
Definition
catch_benchmark.cpp:20
Catch::BenchmarkLooper::increment
void increment()
Definition
catch_benchmark.h:44
Catch::BenchmarkLooper::needsMoreIterations
auto needsMoreIterations() -> bool
Definition
catch_benchmark.cpp:23
Catch::BenchmarkLooper::BenchmarkLooper
BenchmarkLooper(StringRef name)
Definition
catch_benchmark.h:30
Catch::StringRef
Definition
catch.hpp:522
Catch
Definition
231-Cfg-OutputStreams.cpp:32
uint64_t
unsigned __int64 uint64_t
Definition
stdint.h:136
libraries
sys-vm
external
Catch2
include
internal
catch_benchmark.h
Generated by
1.12.0