Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Macros | Functions | Variables
timer.cpp File Reference
#include "precompiled.h"
#include "lib/timer.h"
#include <sstream>
#include <numeric>
#include <cmath>
#include <cfloat>
#include <cstdarg>
#include "lib/module_init.h"
#include "lib/posix/posix_pthread.h"
#include "lib/posix/posix_time.h"
#include "lib/sysdep/cpu.h"

Go to the source code of this file.

Macros

#define HAVE_GETTIMEOFDAY   0
 
#define HAVE_CLOCK_GETTIME   0
 

Functions

void timer_LatchStartTime ()
 timer_Time will subsequently return values relative to the current time. More...
 
static void EnsureMonotonic (double &newTime)
 
double timer_Time ()
 
static Status InitResolution ()
 
double timer_Resolution ()
 
TimerClienttimer_AddClient (TimerClient *tc, const wchar_t *description)
 make the given TimerClient (usually instantiated as static data) ready for use. More...
 
void timer_DisplayClientTotals ()
 display all clients' totals; does not reset them. More...
 
std::wstring StringForSeconds (double seconds)
 internal helper functions for returning an easily readable string (i.e. More...
 
std::wstring StringForCycles (Cycles cycles)
 

Variables

static pthread_mutex_t ensure_monotonic_mutex = PTHREAD_MUTEX_INITIALIZER
 
static double resolution
 
static size_t numClients
 
static TimerClientclients
 

Macro Definition Documentation

#define HAVE_CLOCK_GETTIME   0

Definition at line 56 of file timer.cpp.

#define HAVE_GETTIMEOFDAY   0

Definition at line 50 of file timer.cpp.

Function Documentation

static void EnsureMonotonic ( double &  newTime)
static

Definition at line 88 of file timer.cpp.

static Status InitResolution ( )
static

Definition at line 126 of file timer.cpp.

std::wstring StringForCycles ( Cycles  cycles)

Definition at line 220 of file timer.cpp.

std::wstring StringForSeconds ( double  seconds)

internal helper functions for returning an easily readable string (i.e.

re-scaled to appropriate units)

Definition at line 204 of file timer.cpp.

TimerClient* timer_AddClient ( TimerClient tc,
const wchar_t description 
)

make the given TimerClient (usually instantiated as static data) ready for use.

returns its address for TIMER_ADD_CLIENT's convenience. this client's total (which is increased by a BillingPolicy) will be displayed by timer_DisplayClientTotals. notes:

  • may be called at any time;
  • always succeeds (there's no fixed limit);
  • free() is not needed nor possible.
  • description must remain valid until exit; a string literal is safest.

Definition at line 166 of file timer.cpp.

void timer_DisplayClientTotals ( )

display all clients' totals; does not reset them.

typically called at exit.

Definition at line 181 of file timer.cpp.

void timer_LatchStartTime ( )

timer_Time will subsequently return values relative to the current time.

Definition at line 74 of file timer.cpp.

double timer_Resolution ( )
Returns
resolution [s] of the timer.

Definition at line 145 of file timer.cpp.

double timer_Time ( )
Returns
high resolution (> 1 us) timestamp [s].

Definition at line 98 of file timer.cpp.

Variable Documentation

TimerClient* clients
static

Definition at line 163 of file timer.cpp.

pthread_mutex_t ensure_monotonic_mutex = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 85 of file timer.cpp.

size_t numClients
static

Definition at line 162 of file timer.cpp.

double resolution
static

Definition at line 124 of file timer.cpp.