MyraMath
myramath
utility
Timer.h
Go to the documentation of this file.
1
// ========================================================================= //
2
// This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3
// and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4
// ========================================================================= //
5
6
#ifndef MYRAMATH_UTILITY_TIMER_H
7
#define MYRAMATH_UTILITY_TIMER_H
8
14
#include <myramath/utility/detail/LIBPUBLIC.h>
15
16
namespace
myra
{
17
19
class
LIBPUBLIC
Timer
20
{
21
22
public
:
23
25
Timer
();
26
28
Timer
(
const
Timer
& that);
29
31
double
elapsed_time()
const
;
32
34
double
reset();
35
36
private
:
37
38
// Returns current time (in microseconds, measured from an implementation-defined epoch).
39
double
now()
const
;
40
41
// Measures the duration since the last time reset() was called, in microseconds.
42
double
start;
43
44
};
45
47
template
<
class
Lambda>
double
ticktock
(
const
Lambda& f)
48
{
Timer
t; f();
return
t.
elapsed_time
(); }
49
51
void
sleep(
double
time);
52
53
}
// namespace myra
54
55
#endif
myra
Definition:
syntax.dox:1
myra::Timer
Measures elapsed time.
Definition:
Timer.h:19
myra::ticktock
double ticktock(const Lambda &f)
Measures the time (in seconds) required to execute a given Lambda.
Definition:
Timer.h:47
myra::Timer::elapsed_time
double elapsed_time() const
Returns elapsed time in seconds since last call to reset()
Definition:
Timer.cpp:18
Generated on Sat Jul 8 2023 16:46:53 for MyraMath by
1.8.13