libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
benchmark.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_CORE
13#include <cmath>
14#include <promeki/namespace.h>
15#include <promeki/sharedptr.h>
17#include <promeki/timestamp.h>
18#include <promeki/pair.h>
19#include <promeki/list.h>
20#include <promeki/string.h>
21
22PROMEKI_NAMESPACE_BEGIN
23
58class Benchmark {
59 PROMEKI_SHARED_FINAL(Benchmark)
60 public:
62 using Ptr = SharedPtr<Benchmark>;
64 using List = ::promeki::List<Benchmark>;
66 using PtrList = ::promeki::List<Ptr>;
67
69 using Id = StringRegistry<"Benchmark">::Item;
70
72 struct Entry {
73 Id id;
74 TimeStamp timestamp;
75 };
76
78 using EntryList = ::promeki::List<Entry>;
79
81 Benchmark() = default;
82
87 void stamp(Id id) {
88 _entries.pushToBack({id, TimeStamp::now()});
89 return;
90 }
91
97 void stamp(Id id, const TimeStamp &ts) {
98 _entries.pushToBack({id, ts});
99 return;
100 }
101
106 const EntryList &entries() const { return _entries; }
107
112 size_t size() const { return _entries.size(); }
113
118 bool isEmpty() const { return _entries.isEmpty(); }
119
121 void clear() {
122 _entries.clear();
123 return;
124 }
125
132 double duration(Id fromId, Id toId) const;
133
134 private:
135 EntryList _entries;
136};
137
138PROMEKI_NAMESPACE_END
139
140#endif // PROMEKI_ENABLE_CORE