runtime.hh 671 Bytes
Newer Older
phlo's avatar
phlo committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#ifndef RUNTIME_HH_
#define RUNTIME_HH_

#include <chrono>

namespace ConcuBinE::runtime {

//==============================================================================
// functions
//==============================================================================

// measure runtime of a given function
//
template <class Functor, class Duration = std::chrono::milliseconds>
inline long measure (const Functor & fun)
{
  const auto begin = std::chrono::high_resolution_clock::now();
  fun();
  const auto end = std::chrono::high_resolution_clock::now();
  return std::chrono::duration_cast<Duration>(end - begin).count();
}

} // namespace ConcuBinE::runtime

#endif