33 #ifndef YB_INC_ytest_timing_hpp_
34 #define YB_INC_ytest_timing_hpp_ 1
62 template<
typename _fNow,
typename _fCallable,
typename... _tParams>
64 once(_fNow now, _fCallable&&
f, _tParams&&...
args) -> decltype(now() - now())
77 template<
typename _fCallable,
typename... _tParams>
81 const std::clock_t cl(std::clock());
84 return double(clock() - cl) / CLOCKS_PER_SEC;
94 template<
class _fNow,
typename _fCallable,
typename... _tParams>
96 total(
size_t n, _fNow now, _fCallable&&
f, _tParams&&...
args)
97 -> decltype(now() - now())
101 for(
size_t i(0); i != n; ++i)
111 template<
typename _fCallable,
typename... _tParams>
115 const std::clock_t cl(std::clock());
117 for(
size_t i(0); i != n; ++i)
119 return double(clock() - cl) / CLOCKS_PER_SEC;
127 template<
typename... _tParams>
yconstfn const string _tParams && args
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
auto once(_fNow now, _fCallable &&f, _tParams &&...args) -> decltype(now()-now())
测试指定函数执行一次的时间。
double once_c(_fCallable &&f, _tParams &&...args)
测试指定函数执行一次的时间。
auto average(size_t n, _tParams &&...args) -> decltype(timing::total(n, std::forward< decltype(args)>(args)...)/n)
测试指定函数执行若干次的平均时间。
auto total(size_t n, _fNow now, _fCallable &&f, _tParams &&...args) -> decltype(now()-now())
测试指定函数执行若干次的总时间。
double total_c(size_t n, _fCallable &&f, _tParams &&...args)
测试指定函数执行若干次的总时间。