corrected saving and eval of fields over time

This commit is contained in:
Vasco C. B. Ferreira
2026-06-26 11:40:10 +02:00
parent 26d0637987
commit 006bd19fe2
10 changed files with 373 additions and 403 deletions
+12 -20
View File
@@ -3,35 +3,27 @@
#include <chrono>
template <typename real>
class stopwatch
{
template <typename real> class stopwatch {
public:
void reset();
real elapsed();
void reset();
real elapsed();
private:
using clock = std::chrono::high_resolution_clock;
clock::time_point t0 { clock::now() };
using clock = std::chrono::high_resolution_clock;
clock::time_point t0{clock::now()};
};
template <typename real> inline
void stopwatch<real>::reset()
{
t0 = clock::now();
template <typename real> inline void stopwatch<real>::reset() {
t0 = clock::now();
}
template <typename real> inline
real stopwatch<real>::elapsed()
{
using seconds = std::chrono::duration<real,std::ratio<1,1>>;
template <typename real> inline real stopwatch<real>::elapsed() {
using seconds = std::chrono::duration<real, std::ratio<1, 1>>;
auto tnow = clock::now();
auto duration = std::chrono::duration_cast<seconds>( tnow - t0 );
auto tnow = clock::now();
auto duration = std::chrono::duration_cast<seconds>(tnow - t0);
return duration.count();
return duration.count();
}
#endif // STOPWATCH_H