time.hpp 495 Bytes
Newer Older
Paul's avatar
Paul committed
1
2
3
4
#ifndef MIGRAPH_GUARD_RTGLIB_TIME_HPP
#define MIGRAPH_GUARD_RTGLIB_TIME_HPP

#include <chrono>
5
#include <migraph/config.hpp>
Paul's avatar
Paul committed
6

7
namespace migraph { inline namespace MIGRAPH_INLINE_NS {
Paul's avatar
Paul committed
8

Paul's avatar
Paul committed
9
template <class Duration, class F>
Paul's avatar
Paul committed
10
11
12
13
14
15
16
17
auto time(F f)
{
    auto start = std::chrono::steady_clock::now();
    f();
    auto finish = std::chrono::steady_clock::now();
    return std::chrono::duration_cast<Duration>(finish - start).count();
}

18
} // inline namespace MIGRAPH_INLINE_NS
Paul's avatar
Paul committed
19
20
21
} // namespace migraph

#endif