Initial commit
This commit is contained in:
commit
4f4397b3e1
48 changed files with 2002 additions and 0 deletions
29
VectorFiller/atlas/time/time.h
Normal file
29
VectorFiller/atlas/time/time.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// -*- mode: c++ -*-
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace atlas::time {
|
||||
template <typename Duration>
|
||||
class Timer {
|
||||
public:
|
||||
using duration_type = Duration;
|
||||
|
||||
virtual ~Timer() = default;
|
||||
virtual auto start() -> void = 0;
|
||||
virtual auto elapsed() const -> duration_type;
|
||||
|
||||
template <typename T>
|
||||
struct TimerResult {
|
||||
T value;
|
||||
duration_type duration;
|
||||
};
|
||||
|
||||
template <typename F>
|
||||
[[nodiscard]] auto measure(F&& f) -> TimerResult<decltype(f())>
|
||||
{
|
||||
start();
|
||||
auto v = f();
|
||||
return { v, elapsed() };
|
||||
}
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue