summaryrefslogtreecommitdiff
path: root/tiger-compiler/lib/misc/timer.hxx
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/lib/misc/timer.hxx
add: added projectsHEADmain
Diffstat (limited to 'tiger-compiler/lib/misc/timer.hxx')
-rw-r--r--tiger-compiler/lib/misc/timer.hxx50
1 files changed, 50 insertions, 0 deletions
diff --git a/tiger-compiler/lib/misc/timer.hxx b/tiger-compiler/lib/misc/timer.hxx
new file mode 100644
index 0000000..6e4ceb5
--- /dev/null
+++ b/tiger-compiler/lib/misc/timer.hxx
@@ -0,0 +1,50 @@
+/**
+ ** \file misc/timer.hxx
+ ** \brief Inline methods for misc/timer.hh.
+ */
+
+#pragma once
+
+#include <misc/contract.hh>
+#include <misc/timer.hh>
+
+namespace misc
+{
+ inline void timer::push(int i)
+ {
+ precondition(this->intmap.find(i) != this->intmap.end());
+ this->push(this->intmap[i]);
+ }
+
+ inline void timer::pop([[maybe_unused]] const std::string& task_name)
+ {
+ precondition(this->tasksmap[task_name] == this->tasks.top());
+ this->pop();
+ }
+
+ inline void timer::pop(int i) { this->pop(this->intmap[i]); }
+
+ inline void timer::dump_on_destruction(std::ostream& out)
+ {
+ this->dump_stream = &out;
+ }
+
+ inline void timer::start() { this->total.start(); }
+
+ inline void timer::stop() { this->total.stop(); }
+
+ inline timer::time::time()
+ : user(0)
+ , sys(0)
+ , wall(0)
+ {}
+
+ inline timer::time& timer::time::operator+=(const time& rhs)
+ {
+ this->wall += rhs.wall;
+ this->user += rhs.user;
+ this->sys += rhs.sys;
+ return *this;
+ }
+
+} // namespace misc