Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Related Pages

Timer - timekeeping functions


Detailed Description

Author:
Michael Schulz
Date:
somewhen in 1998
This module exports functions for measuring the time spent in various parts of the application. The time measured is always user time + kernel time.


Defines

#define MyMAXLONG   ((long)~(1L << ((8 * (int)sizeof(long)) - 1)))

Typedefs

typedef timeval TimerStruct * Timer
typedef clock_t TimerFast

Functions

void expire (int n)
unsigned long timerElapsed (Timer timer)
unsigned long timerElapsedFast (TimerFast timer)
void timerFree (Timer timer)
void timerInitialize (void)
Timer timerNew (void)
void timerSetAlarm (long unsigned int limit)
void timerStart (Timer timer)
TimerFast timerStartFast (void)
void timerStopAlarm (void)

Variables

double timerClockTicks = -1
Boolean timerExpired
Boolean timerExpired


Define Documentation

#define MyMAXLONG   ((long)~(1L << ((8 * (int)sizeof(long)) - 1)))
 

a local macro to define the maximal long value Definition at line 28 of file timer.h.


Typedef Documentation

typedef struct timeval TimerStruct* Timer
 

the slow timer Definition at line 32 of file timer.h.

Referenced by cmdChunk(), cmdIncrementalCompletion(), cmdISearch(), cmdNewnet(), cnBuildEdges(), cnBuildNodes(), timerElapsed(), timerFree(), timerNew(), and timerStart().

typedef clock_t TimerFast
 

the fast timer Definition at line 31 of file timer.h.

Referenced by timerElapsedFast(), and timerStartFast().


Function Documentation

void expire int  n  )  [static]
 

Signal handler for when timer expires.

this function sets timerexpired. Definition at line 156 of file timer.c.

References timerExpired, and TRUE.

Referenced by timerSetAlarm().

unsigned long timerElapsed Timer  timer  ) 
 

Return milliseconds elapsed since last timerStart() on this timer.

this function returns the difference between the time used so far and a time determined earlier by timerstart() in milliseconds. Definition at line 130 of file timer.c.

References CDG_ERROR, cdgPrintf(), and Timer.

Referenced by cmdChunk(), cmdIncrementalCompletion(), cmdISearch(), cmdNewnet(), cnBuildEdges(), cnBuildNodes(), comApprove(), comCompareAllLvPairs(), and comCompareWithContext().

unsigned long timerElapsedFast TimerFast  timer  ) 
 

return milliseconds elapsed since last timerStartFast

this function returns the difference between the time used so far and a time determined earlier by timerstartfast() in milliseconds. Definition at line 72 of file timer.c.

References timerClockTicks, and TimerFast.

void timerFree Timer  timer  ) 
 

frees the timer memory

this function deallocates a timer. Definition at line 116 of file timer.c.

References NULL, and Timer.

Referenced by cmdChunk(), cmdIncrementalCompletion(), cmdISearch(), cmdNewnet(), cnBuildEdges(), cnBuildNodes(), and comFreeApprover().

void timerInitialize void   ) 
 

timerInitialize

this function stops any alarms pending and initializes the variable timerclockticks. Definition at line 244 of file timer.c.

References timerClockTicks, and timerStopAlarm().

Referenced by cdgInitialize().

Timer timerNew void   ) 
 

allocates memory for the timer and calls timerStart Definition at line 103 of file timer.c.

References Timer, and timerStart().

Referenced by cmdChunk(), cmdIncrementalCompletion(), cmdISearch(), cmdNewnet(), cnBuildEdges(), cnBuildNodes(), and comNewApprover().

void timerSetAlarm long unsigned int  limit  ) 
 

Set an alarm-clock that will set the flag timerExpired after ``limit'' milliseconds.

this function sets a time limit for the completion of a task. after limit milliseconds the variable timerexpired is asynchronously set to~1 by expire(). this can be used as follows:

\/\* build lvs for one second \*\/

void fastbuildvalues( constraintnet net, leveldecl level, ConstraintNode cn, List modifiers) {

LexemNode modifiee; * LevelValue lv;

int i; List l; String label;

timerSetAlarm(1000);

for (i = 0; i < vectorSize(net->lexemgraph->nodes); i++) { modifiee = (LexemNode) vectorElement(net->lexemgraph->nodes, i)

for (l = level->labels; l != NULL; l = l->next) { label = (String) l->item;

lv = lvNew(modifiers, level, label, modifiee); vectorAddElement(node->values, lv); }

if(timerExpired) { break; }

}

} Definition at line 204 of file timer.c.

References expire(), FALSE, NULL, and timerExpired.

Referenced by cmdFrobbing(), and cmdShift().

void timerStart Timer  timer  ) 
 

Store number of cycles elapsed since program start (user + system) in timer.

This function performs a call to getrusage() and fills the corresponding fields in the Timer structure. Definition at line 88 of file timer.c.

References NULL, and Timer.

Referenced by comApprove(), comCompareAllLvPairs(), comCompareWithContext(), and timerNew().

TimerFast timerStartFast void   ) 
 

return clocks elapse since program start (user + system)

this function returns the time used so far by the process, as computed by the system function clock()=. Definition at line 61 of file timer.c.

References TimerFast.

void timerStopAlarm void   ) 
 

stop the alarm clock

This function cancels the alarm set by timerSetAlarm(). Definition at line 229 of file timer.c.

References FALSE, and timerExpired.

Referenced by cmdFrobbing(), cmdShift(), and timerInitialize().


Variable Documentation

double timerClockTicks = -1 [static]
 

initialized correctly in timerInitialize Definition at line 48 of file timer.c.

Referenced by timerElapsedFast(), and timerInitialize().

Boolean timerExpired
 

This variable timerExpired= is a flag to be set after a user-defined timespan has elapsed. Definition at line 46 of file timer.c.

Referenced by expire(), timerSetAlarm(), and timerStopAlarm().

Boolean timerExpired
 

This variable timerExpired= is a flag to be set after a user-defined timespan has elapsed. Definition at line 46 of file timer.c.

Referenced by expire(), timerSetAlarm(), and timerStopAlarm().


CDG 0.95 (20 Oct 2004)