From ba263efb92ffba13212cf4ee6fd15b4339349fb3 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Fri, 23 Sep 2022 09:02:59 -0700 Subject: Basic IPC stats support --- infra/stat.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 infra/stat.h (limited to 'infra/stat.h') 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 @@ +#pragma once + +#include +#include + +#include "infra/sim.h" + +namespace infra { + struct stat : public sim { + std::string name; + std::uint64_t numerator = 0; + std::uint64_t denominator = 0; + + stat(std::string name) + : name(std::move(name)) + { } + + ~stat() { + fmt::print("# {} {}\n", name, (double)numerator/(double)denominator); + } + + void unclock() { + ++denominator; + } + + stat & operator++() { + ++numerator; + return *this; + } + + stat & operator++(int) { + return operator++(); + } + }; +} -- cgit v1.2.3