summaryrefslogtreecommitdiff
path: root/infra/stat.h
diff options
context:
space:
mode:
authorJulian Blake Kongslie2022-09-23 09:02:59 -0700
committerJulian Blake Kongslie2022-09-23 09:02:59 -0700
commitba263efb92ffba13212cf4ee6fd15b4339349fb3 (patch)
tree7c0329f52fe924ad8faac2859693e88a7f8d4abe /infra/stat.h
parentAdd a trivial indirect jump predictor and matching test (diff)
downloadprocmodel-ba263efb92ffba13212cf4ee6fd15b4339349fb3.tar.xz
Basic IPC stats support
Diffstat (limited to '')
-rw-r--r--infra/stat.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/infra/stat.h b/infra/stat.h
new file mode 100644
index 0000000..f1ca75a
--- /dev/null
+++ b/infra/stat.h
@@ -0,0 +1,35 @@
1#pragma once
2
3#include <fmt/format.h>
4#include <utility>
5
6#include "infra/sim.h"
7
8namespace infra {
9 struct stat : public sim {
10 std::string name;
11 std::uint64_t numerator = 0;
12 std::uint64_t denominator = 0;
13
14 stat(std::string name)
15 : name(std::move(name))
16 { }
17
18 ~stat() {
19 fmt::print("# {} {}\n", name, (double)numerator/(double)denominator);
20 }
21
22 void unclock() {
23 ++denominator;
24 }
25
26 stat & operator++() {
27 ++numerator;
28 return *this;
29 }
30
31 stat & operator++(int) {
32 return operator++();
33 }
34 };
35}