#ifndef TIMER_H_
#define TIMER_H_

#include <chrono>
#include <functional>
#include <utility>

template <class TimeUnit = std::chrono::microseconds,
          class ClockType = std::chrono::steady_clock>
struct measure {
  template <class F, class... Args>
  static auto duration(F &&func, Args &&...args) {
    auto start = ClockType::now();
    auto retVal =
        std::invoke(std::forward<F>(func), std::forward<Args>(args)...);
    auto end = ClockType::now();
    return std::make_pair(retVal,
                          std::chrono::duration_cast<TimeUnit>(end - start));
  }
};

#endif // TIMER_H_
