21#include <plf_nanotimer.h>
36 std::string
unit =
"ns";
74 std::chrono::steady_clock::time_point t_start,
t_end;
79 inline void start() { t_start = std::chrono::steady_clock::now(); }
82 t_end = std::chrono::steady_clock::now();
84 std::chrono::duration_cast<std::chrono::nanoseconds>(
t_end - t_start).count());
154 acc += t.elasped_sec();
double f64
Alias for double.
std::uint32_t u32
32 bit unsigned integer
Class FunctionTimer measures the time it takes to execute a function.
f64 func_time_sec()
Returns the average time it takes to execute the function.
void time_func(Func &&f)
Measures the time it takes to execute a function.
Class Timer measures the time elapsed since the timer was started.
plf::nanotimer timer
Internal timer.
std::string get_time_str() const
Converts the stored nanosecond time to a string representation.
void end()
Stops the timer and stores the elapsed time in nanoseconds.
f64 elasped_sec() const
Converts the stored nanosecond time to a floating point representation in seconds.
void start()
Starts the timer.
f64 nanosec
Time in nanosecond.
namespace for basic c++ utilities
std::string nanosec_to_time_str(double nanosec)
Convert nanoseconds to a human-readable string representation.
f64 timeitfor(Func &&f, f64 max_duration=1)
Measures the average time it takes to execute a function until a maximum duration is reached.
f64 timeit(Func &&f, u32 relaunch=1)
Measures the average time it takes to execute a function.
BenchmarkResult benchmark_pow_len(std::function< f64(u32)> func, u32 start, u32 end, f64 pow_exp)
Benchmark a function with input values following a power law.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
Structure to store the results of a benchmark.
std::vector< f64 > counts
The counts of the benchmark.
std::vector< f64 > times
The times of the benchmark.