Version 6.3
Copyright © 2005 - 2012 Lowell D. Thomas
APG
  … ABNF Parser Generator
All Data Structures Files Functions Variables Typedefs Macros Pages
Functions
timer.c File Reference

A timer component API. More...

#include "ApgUtilities.h"

Go to the source code of this file.

Functions

void * vpTimerCtor (void *vpMemCtx)
 
void vTimerDtor (void *vpCtx)
 
apg_uint uiTimerStart (void *vpCtx)
 
apg_uint uiTimerStop (void *vpCtx)
 
apg_uint uiTimerRates (void *vpCtx, double *dpRates, apg_uint uiLen, double dConversion)
 
double dTimerStartTime (void *vpCtx, double dConversion)
 
double dTimerStopTime (void *vpCtx, double dConversion)
 
double dTimerDuration (void *vpCtx, double dConversion)
 

Detailed Description

A timer component API.

A convenient timer API used for the timing studies in the APG examples. Uses a "context handle" or pointer to an opaque data structure for data encapsulation.

Definition in file timer.c.

Function Documentation

◆ dTimerDuration()

double dTimerDuration ( void *  vpCtx,
double  dConversion 
)

The timed duration in specified units.

Parameters
vpCtxcontext handle previously returned from vpTimerCtor()
dConversiona time units conversion factor. Use 1 for seconds, 1000 for milliseconds, etc.

The following #define macros are available:

APG_TIMER_SEC      - return value in seconds
APG_TIMER_MILLISEC - return value in milliseconds
APG_TIMER_MICROSEC - return value in microseconds
See also
vpTimerCtor()
uiTimerStart()
uiTimerStop()
Returns
the timed duration in units specified by the dConversion parameter

Definition at line 237 of file timer.c.

◆ dTimerStartTime()

double dTimerStartTime ( void *  vpCtx,
double  dConversion 
)

Get the start time in specified units.

Parameters
vpCtxcontext handle previously returned from vpTimerCtor()
dConversiona time units conversion factor. Use 1 for seconds, 1000 for milliseconds, etc.

The following #define macros are available:

APG_TIMER_SEC      - return value in seconds
APG_TIMER_MILLISEC - return value in milliseconds
APG_TIMER_MICROSEC - return value in microseconds
See also
vpTimerCtor()
uiTimerStart()
uiTimerStop()
Returns
the start time in units specified by the dConversion parameter

Definition at line 185 of file timer.c.

◆ dTimerStopTime()

double dTimerStopTime ( void *  vpCtx,
double  dConversion 
)

Get the stop time in specified units.

Parameters
vpCtxcontext handle previously returned from vpTimerCtor()
dConversiona time units conversion factor. Use 1 for seconds, 1000 for milliseconds, etc.

The following #define macros are available:

APG_TIMER_SEC      - return value in seconds
APG_TIMER_MILLISEC - return value in milliseconds
APG_TIMER_MICROSEC - return value in microseconds
See also
vpTimerCtor()
uiTimerStart()
uiTimerStop()
Returns
the stop time in units specified by the dConversion parameter

Definition at line 211 of file timer.c.

◆ uiTimerRates()

apg_uint uiTimerRates ( void *  vpCtx,
double *  dpRates,
apg_uint  uiLen,
double  dConversion 
)

Convert any value into a rate (value/duration).

eg. If the parser parsed uiCharacters characters between the start and stop times, uiTimerRates(vpCtx, &uiCharacters, 1, APG_TIMER_MILLISEC) would overrite uiCharacters with uiCharacters/duration in the specified units.

Parameters
vpCtxcontext handle previously returned from vpTimerCtor()
dpRatesan array of values to convert to rates
uiLenthe number of values in the array.
dConversiona time units conversion factor. Use 1 for seconds, 1000 for milliseconds, etc.

The following #define macros are available:

APG_TIMER_SEC      - return value in seconds
APG_TIMER_MILLISEC - return value in milliseconds
APG_TIMER_MICROSEC - return value in microseconds
See also
vpTimerCtor()
uiTimerStart()
uiTimerStop()
Returns
true on success, false if the context handle vpCtx is invalid or the duration of the timer is 0.0.
The rates overwrite the original values in the dpRates array.

Definition at line 151 of file timer.c.

◆ uiTimerStart()

apg_uint uiTimerStart ( void *  vpCtx)

Start the timer.

Parameters
vpCtxcontext handle previously returned from vpTimerCtor()
See also
vpTimerCtor()
uiTimerStop()
Returns
the start time in internal clock units

Definition at line 96 of file timer.c.

◆ uiTimerStop()

apg_uint uiTimerStop ( void *  vpCtx)

Stop the timer.

Parameters
vpCtxcontext handle previously returned from vpTimerCtor()
See also
vpTimerCtor()
uiTimerStart()
Returns
the stop time in internal clock units

Definition at line 117 of file timer.c.

◆ vpTimerCtor()

void* vpTimerCtor ( void *  vpMemCtx)

Constructs a timer component.

Parameters
vpMemCtxpointer to a Memory component
See also
Memory.c
vpMemCtor()
Returns
a context handle

Definition at line 51 of file timer.c.

◆ vTimerDtor()

void vTimerDtor ( void *  vpCtx)

Destroys a timer component.

Parameters
vpCtxcontext handle previously returned from vpTimerCtor()
See also
vpTimerCtor()

Definition at line 80 of file timer.c.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/licenses.html or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.