stopwatch.h File Reference

A very basic stopwatch-like timer. More...

#include <sys/resource.h>
#include <sys/time.h>
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  struct_stopwatch_t
 Defines a very basic stopwatch-like timer. More...

Defines

#define _TIFA_STOPWATCH_H_

Typedefs

typedef struct struct_stopwatch_t stopwatch_t
 Equivalent to struct struct_stopwatch_t.

Functions

void init_stopwatch (stopwatch_t *const watch)
 Inits a stopwatch_t.
void start_stopwatch (stopwatch_t *const watch)
 Starts a stopwatch_t.
void stop_stopwatch (stopwatch_t *const watch)
 Stop a stopwatch_t.
void reset_stopwatch (stopwatch_t *const watch)
 Reset a stopwatch_t.
double get_stopwatch_elapsed (stopwatch_t *const watch)
 Returns the elapsed time measured.


Detailed Description

A very basic stopwatch-like timer.

Author:
Jerome Milan
Date:
Fri Jun 10 2011
Version:
2011-06-10
This file implements a very basic stopwatch-like timer (with microsecond precision) based on the rusage structure and using the getrusage function.

Definition in file stopwatch.h.


Define Documentation

#define _TIFA_STOPWATCH_H_

Standard include guard.

Definition at line 37 of file stopwatch.h.


Function Documentation

double get_stopwatch_elapsed ( stopwatch_t *const   watch  ) 

Returns the elapsed time measured.

Returns the elapsed time measured by watch in seconds.

Warning:
The returned result is only meaningful if the stopwatch is not running (i.e. it has been stopped with the stop_stopwatch function).
Parameters:
[in] watch The stopwatch_t used for timing.

void init_stopwatch ( stopwatch_t *const   watch  ) 

Inits a stopwatch_t.

Initializes the stopwatch_t pointed to by watch.

Parameters:
watch The stopwatch_t to init.

void reset_stopwatch ( stopwatch_t *const   watch  ) 

Reset a stopwatch_t.

Reset the stopwatch_t pointed to by watch. The stopwatch is not stopped and will continue to run unless it was already stopped.

Parameters:
watch The stopwatch_t to reset.

void start_stopwatch ( stopwatch_t *const   watch  ) 

Starts a stopwatch_t.

Starts the stopwatch_t pointed to by watch.

Note:
Consecutive calls to start_stopwatch are without effect.
Parameters:
watch The stopwatch_t to start.

void stop_stopwatch ( stopwatch_t *const   watch  ) 

Stop a stopwatch_t.

Stop the stopwatch_t pointed to by watch. Successive calls to start_stopwatch and stop_stopwatch are cumulative. In other words, the stopwatch's state holds the time elapsed during all previous time intervals defined by a call to start_stopwatch followed by a call to stop_stopwatch (provided that the stopwatch was not reset with reset_stopwatch).

Note:
Consecutive calls to stop_stopwatch are without effect.
Parameters:
watch The stopwatch_t to stop.


Generated on Fri Jun 17 11:10:12 2011 for TIFA by Doxygen 1.5.5