Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Profiler.hpp
1#pragma once
2
3#include <chrono>
4#include <type_traits>
5#include <utility>
6
7namespace util {
8
19template <typename U = std::chrono::milliseconds, typename FnType>
20[[nodiscard]] auto
21timed(FnType&& func)
22{
23 auto start = std::chrono::system_clock::now();
24
25 if constexpr (std::is_same_v<decltype(func()), void>) {
26 func();
27 return std::chrono::duration_cast<U>(std::chrono::system_clock::now() - start).count();
28 } else {
29 auto ret = func();
30 auto elapsed =
31 std::chrono::duration_cast<U>(std::chrono::system_clock::now() - start).count();
32 return std::make_pair(std::move(ret), std::move(elapsed));
33 }
34}
35
36} // namespace util
This namespace contains various utilities.
Definition AccountUtils.hpp:11
auto timed(FnType &&func)
Profiler function to measure the time a function execution consumes.
Definition Profiler.hpp:21