Toolbox
snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
toolbox
bm
Suite.cpp
Go to the documentation of this file.
1
// The Reactive C++ Toolbox.
2
// Copyright (C) 2021 Reactive Markets Limited
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License");
5
// you may not use this file except in compliance with the License.
6
// You may obtain a copy of the License at
7
//
8
// http://www.apache.org/licenses/LICENSE-2.0
9
//
10
// Unless required by applicable law or agreed to in writing, software
11
// distributed under the License is distributed on an "AS IS" BASIS,
12
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
// See the License for the specific language governing permissions and
14
// limitations under the License.
15
16
#include "
Suite.hpp
"
17
18
#include <
toolbox/hdr/Utility.hpp
>
19
20
#include <boost/io/ios_state.hpp>
21
22
#include <iomanip>
23
24
namespace
toolbox::bm
{
25
using namespace
std
;
26
27
BenchmarkSuite::BenchmarkSuite
(std::ostream& os,
double
value_scale)
28
: os_{os}
29
, value_scale_{value_scale}
30
{
31
boost::io::ios_all_saver
all_saver
{os};
32
33
// clang-format off
34
os <<
left
<<
setw
(45) <<
"NAME"
35
<<
right
<<
setw
(15) <<
"COUNT"
36
<<
right
<<
setw
(10) <<
"MIN"
37
<<
right
<<
setw
(10) <<
"%50"
38
<<
right
<<
setw
(10) <<
"%95"
39
<<
right
<<
setw
(10) <<
"%99"
40
<<
right
<<
setw
(10) <<
"%99.9"
41
<<
right
<<
setw
(10) <<
"%99.99"
42
<<
endl
;
43
// clang-format on
44
45
// Separator.
46
os <<
setw
(120) <<
setfill
(
'-'
) <<
'-'
<<
setfill
(
' '
) <<
endl
;
47
}
48
49
void
BenchmarkSuite::report
(
const
char
* name,
Histogram
& h)
50
{
51
boost::io::ios_all_saver
all_saver
{os_};
52
53
// clang-format off
54
os_ <<
left
<<
setw
(45) << name
55
<<
right
<<
setw
(15) << h.
total_count
()
56
<<
right
<<
setw
(10) << h.
min
() / value_scale_
57
<<
right
<<
setw
(10) <<
value_at_percentile
(h, 50) / value_scale_
58
<<
right
<<
setw
(10) <<
value_at_percentile
(h, 95) / value_scale_
59
<<
right
<<
setw
(10) <<
value_at_percentile
(h, 99) / value_scale_
60
<<
right
<<
setw
(10) <<
value_at_percentile
(h, 99.9) / value_scale_
61
<<
right
<<
setw
(10) <<
value_at_percentile
(h, 99.99) / value_scale_
62
<<
endl
;
63
// clang-format on
64
}
65
66
}
// namespace toolbox::bm
Suite.hpp
toolbox::bm::BenchmarkSuite::report
void report(const char *name, Histogram &hist)
Definition
Suite.cpp:49
toolbox::bm::BenchmarkSuite::BenchmarkSuite
BenchmarkSuite(std::ostream &os, double value_scale=1.0)
Definition
Suite.cpp:27
toolbox::Histogram
A High Dynamic Range (HDR) Histogram.
Definition
Histogram.hpp:64
toolbox::hdr::Histogram::total_count
std::int64_t total_count() const noexcept
Definition
Histogram.hpp:85
toolbox::hdr::Histogram::min
std::int64_t min() const noexcept
Get minimum value from the histogram. Will return 2^63-1 if the histogram is empty.
Definition
Histogram.cpp:120
Utility.hpp
std
STL namespace.
toolbox::bm
Definition
Benchmark.cpp:26
toolbox::hdr::value_at_percentile
int64_t value_at_percentile(const Histogram &h, double percentile) noexcept
Definition
Utility.cpp:51
toolbox::util::bind
constexpr auto bind() noexcept
Definition
Slot.hpp:92
Generated by
1.9.8