Setting up run Component

This commit is contained in:
n0ffie 2024-12-28 01:51:07 +01:00
parent d375f9ca7d
commit 5c8504288b
13 changed files with 586 additions and 157 deletions

View file

@ -3,6 +3,7 @@
#include <iostream>
#include <optional>
#include <assert.h>
#include <types.hpp>
struct timer_result
{
@ -17,12 +18,12 @@ struct Timer {
paused = 1
};
State state = paused;
std::clock_t begin;
std::clock_t elapsed = 0;
std::optional<std::ostream*> out;
std::optional<timer_result*> result;
Timer() : begin(std::clock()) {}
Timer(std::ostream& o) : begin(std::clock()), out(&o) {}
Timer(timer_result& r) : begin(std::clock()), result(&r) {}
@ -43,7 +44,7 @@ struct Timer {
if (state == paused)
begin = 0;
}
Timer(std::ostream& o, timer_result& r, State initial_state) : state(initial_state), begin(std::clock()), out(&o), result(&r)
{
if (state == paused)
@ -99,7 +100,7 @@ struct Timer {
*out.value() << "Total time = " << static_cast<double>(total_time) / CLOCKS_PER_SEC << std::endl;
}
}
~Timer() {
lap();
}