Toolbox snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
Range.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
16#ifndef TOOLBOX_BM_RANGE
17#define TOOLBOX_BM_RANGE
18
19#include <toolbox/Config.h>
20
21#include <chrono>
22
23namespace toolbox {
24inline namespace hdr {
25class Histogram;
26} // namespace hdr
27} // namespace toolbox
28
29namespace toolbox::bm {
30
35 class Iterator {
36 friend constexpr bool operator==(Iterator lhs, Iterator rhs) noexcept
37 {
38 return lhs.val_ == rhs.val_;
39 }
40 friend constexpr bool operator!=(Iterator lhs, Iterator rhs) noexcept
41 {
42 return !(lhs == rhs);
43 }
44
45 public:
46 constexpr explicit Iterator(int val) noexcept
47 : val_{val}
48 {
49 }
50 constexpr auto operator*() const noexcept { return val_; }
51 Iterator& operator++() noexcept
52 {
53 ++val_;
54 return *this;
55 }
56
57 private:
58 int val_{0};
59 };
60
61 public:
62 BenchmarkRange(Histogram& hist, int first, int last) noexcept;
64
65 // Copy.
68
69 // Move.
72
73 auto begin() const noexcept { return Iterator{first_}; }
74 auto end() const noexcept { return Iterator{last_}; }
75
76 private:
77 Histogram& hist_;
78 const int first_;
79 const int last_;
80 std::chrono::time_point<std::chrono::high_resolution_clock> start_;
81};
82
83} // namespace toolbox::bm
84
85#endif // TOOLBOX_BM_RANGE
#define TOOLBOX_API
Definition Config.h:39
auto begin() const noexcept
Definition Range.hpp:73
BenchmarkRange(const BenchmarkRange &)=delete
auto end() const noexcept
Definition Range.hpp:74
BenchmarkRange & operator=(BenchmarkRange &&)=delete
BenchmarkRange & operator=(const BenchmarkRange &)=delete
BenchmarkRange(BenchmarkRange &&)=delete
A High Dynamic Range (HDR) Histogram.
Definition Histogram.hpp:64
constexpr bool operator==(const BasicHandle< PolicyT > &lhs, const BasicHandle< PolicyT > &rhs)
Definition Handle.hpp:91
constexpr bool operator!=(const BasicHandle< PolicyT > &lhs, const BasicHandle< PolicyT > &rhs)
Definition Handle.hpp:97