My Project
programmer's documentation
Functions
cs_timer_stats.h File Reference
#include "cs_defs.h"
#include "cs_timer.h"
#include "cs_time_plot.h"
Include dependency graph for cs_timer_stats.h:

Go to the source code of this file.

Functions

void cs_timer_stats_initialize (void)
 Initialize timer statistics handling. More...
 
void cs_timer_stats_finalize (void)
 Finalize timer statistics handling. More...
 
void cs_timer_stats_set_start_time (int time_id)
 Set a start time for time stats. More...
 
void cs_timer_stats_set_plot_options (cs_time_plot_format_t format, int frequency, int n_buffer_steps, double flush_wtime)
 Set global timer statistics plot options. More...
 
void cs_timer_stats_increment_time_step (void)
 Increment time step for timer statistics. More...
 
int cs_timer_stats_create (const char *parent_name, const char *name, const char *label)
 Create a timer statistics structure. More...
 
int cs_timer_stats_id_by_name (const char *name)
 Return the id of a defined statistic based on its name. More...
 
void cs_timer_stats_set_plot (int id, int plot)
 Enable or disable plotting for a timer statistic. More...
 
int cs_timer_stats_is_active (int id)
 indicate if a timer for a given statistic is currently active. More...
 
void cs_timer_stats_start (int id)
 Start a timer for a given statistic. More...
 
void cs_timer_stats_stop (int id)
 Stop a timer for a given statistic. More...
 
int cs_timer_stats_switch (int id)
 Start a timer for a given statistic, stopping previous timers of the same type which are not a parent, and starting inactive parent timers if necessary. More...
 
void cs_timer_stats_add_diff (int id, const cs_timer_t *t0, const cs_timer_t *t1)
 Add a timing range to an inactive timer. More...
 
void cs_timer_stats_define_defaults (void)
 Define default timer statistics. More...
 

Function Documentation

◆ cs_timer_stats_add_diff()

void cs_timer_stats_add_diff ( int  id,
const cs_timer_t t0,
const cs_timer_t t1 
)

Add a timing range to an inactive timer.

This does not modify parent timers, so consistency of active and inactive timers must be ensured by the caller.

Parameters
[in]idid of statistic
[in]t0oldest timer value
[in]t1most recent timer value

◆ cs_timer_stats_create()

int cs_timer_stats_create ( const char *  parent_name,
const char *  name,
const char *  label 
)

Create a timer statistics structure.

Parameters
[in]parent_namename of parent statistic, or NULL
[in]nameassociated canonical name
[in]labelassociated label, or NULL
Returns
id of new timer stats structure

◆ cs_timer_stats_define_defaults()

void cs_timer_stats_define_defaults ( void  )

Define default timer statistics.

This creates 2 statistic timer trees, whose roots ids are:

  • 0 for computational operations
  • 1 for computational stages

◆ cs_timer_stats_finalize()

void cs_timer_stats_finalize ( void  )

Finalize timer statistics handling.

◆ cs_timer_stats_id_by_name()

int cs_timer_stats_id_by_name ( const char *  name)

Return the id of a defined statistic based on its name.

If no timer with the given name exists, -1 is returned.

Parameters
[in]namestatistic name
Returns
id of the statistic, or -1 if not found

If no timer with the given name exists, -1 is returned.

Parameters
[in]namestatitic name
Returns
id of the statistic, or -1 if not found

◆ cs_timer_stats_increment_time_step()

void cs_timer_stats_increment_time_step ( void  )

Increment time step for timer statistics.

◆ cs_timer_stats_initialize()

void cs_timer_stats_initialize ( void  )

Initialize timer statistics handling.

This creates 2 statistic timer trees, whose roots ids are:

  • 0 for computational operations
  • 1 for computational stages

◆ cs_timer_stats_is_active()

int cs_timer_stats_is_active ( int  id)

indicate if a timer for a given statistic is currently active.

Parameters
[in]idid of statistic
Returns
1 if active, 0 otherwise

◆ cs_timer_stats_set_plot()

void cs_timer_stats_set_plot ( int  id,
int  plot 
)

Enable or disable plotting for a timer statistic.

By default plotting is enabled for all statistics, except root statistic 1 (as it measures the same total time as root 0, with a different subtree).

This function is only effective before the first call to cs_timer_stats_increment_time_step.

Parameters
[in]idid of statistic
[in]plot0 to disable, 1 to enable

◆ cs_timer_stats_set_plot_options()

void cs_timer_stats_set_plot_options ( cs_time_plot_format_t  format,
int  frequency,
int  n_buffer_steps,
double  flush_wtime 
)

Set global timer statistics plot options.

This function is only effective before the first call to cs_timer_stats_increment_time_step.

Parameters
[in]formatassociated file format
[in]frequencyplot every n time steps
[in]n_buffer_stepsnumber of time steps in output buffer if file is not to be kept open
[in]flush_wtimeelapsed time interval between file flushes (if < 0, no forced flush)

◆ cs_timer_stats_set_start_time()

void cs_timer_stats_set_start_time ( int  time_id)

Set a start time for time stats.

This is useful to shift the time id for restarts. This function must not be called after cs_timer_stats_increment_time_step.

Parameters
[in]time_idassociated starting time id

◆ cs_timer_stats_start()

void cs_timer_stats_start ( int  id)

Start a timer for a given statistic.

Parents of the current statistic are also started, if not active.

If a timer with the same root but different parents is active, we assume the current operation is a subset of the active timer, so the timer is not started, so as to avoid having a sum of parts larger than the total.

Parameters
[in]idid of statistic

◆ cs_timer_stats_stop()

void cs_timer_stats_stop ( int  id)

Stop a timer for a given statistic.

Children of the current statistic are also stopped, if active.

Parameters
[in]idid of statistic

◆ cs_timer_stats_switch()

int cs_timer_stats_switch ( int  id)

Start a timer for a given statistic, stopping previous timers of the same type which are not a parent, and starting inactive parent timers if necessary.

Parameters
[in]idid of statistic
Returns
id of previously active statistic, or -1 in case of error
Parameters
[in]idid of statistic with same root
Returns
id of previously active statistic, or -1 in case of error