Toolbox snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
Utility.hpp
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#ifndef TOOLBOX_HDR_UTILITY
16#define TOOLBOX_HDR_UTILITY
17
18#include <toolbox/Config.h>
19
20#include <cstdint>
21#include <iosfwd>
22
23namespace toolbox {
25inline namespace hdr {
26class Histogram;
27
28TOOLBOX_API std::int64_t min(const Histogram& h) noexcept;
29TOOLBOX_API std::int64_t max(const Histogram& h) noexcept;
30
36TOOLBOX_API std::int64_t value_at_percentile(const Histogram& h, double percentile) noexcept;
37
42TOOLBOX_API double mean(const Histogram& h) noexcept;
43
48TOOLBOX_API double stddev(const Histogram& h) noexcept;
49
51 const Histogram& h;
52 std::int32_t ticks_per_half_distance{5};
53 double value_scale{1000.0};
54};
55
56inline auto put_percentiles(const Histogram& h, std::int32_t ticks_per_half_distance,
57 double value_scale) noexcept
58{
59 return PutPercentiles{h, ticks_per_half_distance, value_scale};
60}
61
62TOOLBOX_API std::ostream& operator<<(std::ostream& os, PutPercentiles pp);
63
64} // namespace hdr
65} // namespace toolbox
66
67#endif // TOOLBOX_HDR_UTILITY
#define TOOLBOX_API
Definition Config.h:39
A High Dynamic Range (HDR) Histogram.
Definition Histogram.hpp:64
int64_t min(const Histogram &h) noexcept
Definition Utility.cpp:41
double mean(const Histogram &h) noexcept
Definition Utility.cpp:66
auto put_percentiles(const Histogram &h, std::int32_t ticks_per_half_distance, double value_scale) noexcept
Definition Utility.hpp:56
int64_t value_at_percentile(const Histogram &h, double percentile) noexcept
Definition Utility.cpp:51
int64_t max(const Histogram &h) noexcept
Definition Utility.cpp:46
ostream & operator<<(ostream &os, PutPercentiles pp)
Definition Utility.cpp:96
double stddev(const Histogram &h) noexcept
Definition Utility.cpp:80
constexpr auto bind() noexcept
Definition Slot.hpp:92
const Histogram & h
Definition Utility.hpp:51
std::int32_t ticks_per_half_distance
Definition Utility.hpp:52