Pyrogenesis  trunk
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"
Include dependency graph for timer.cpp:

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::string StringForSeconds (double seconds)
 internal helper functions for returning an easily readable string (i.e. More...
 
std::string 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
#define HAVE_GETTIMEOFDAY   0

Function Documentation

static void EnsureMonotonic ( double &  newTime)
static
static Status InitResolution ( )
static
std::string StringForCycles ( Cycles  cycles)
std::string StringForSeconds ( double  seconds)

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

re-scaled to appropriate units)

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.
void timer_DisplayClientTotals ( )

display all clients' totals; does not reset them.

typically called at exit.

void timer_LatchStartTime ( )

timer_Time will subsequently return values relative to the current time.

double timer_Resolution ( )
Returns
resolution [s] of the timer.
double timer_Time ( )
Returns
high resolution (> 1 us) timestamp [s].

Variable Documentation

TimerClient* clients
static
pthread_mutex_t ensure_monotonic_mutex = PTHREAD_MUTEX_INITIALIZER
static
size_t numClients
static
double resolution
static