SphinxBase 5prealpha
profile.h File Reference

Implementation of profiling, include counting , timing, cpu clock checking. More...

#include <stdio.h>
#include <sphinxbase/sphinxbase_export.h>
#include <sphinxbase/prim_type.h>

Go to the source code of this file.

Data Structures

struct  pctr_t
 Generic event counter for profiling. More...
 
struct  ptmr_t
 Generic timer structures and functions for coarse-grained performance measurements using standard system calls. More...
 

Functions

SPHINXBASE_EXPORT pctr_tpctr_new (char *name)
 operations of pctr_t
 
SPHINXBASE_EXPORT void pctr_reset (pctr_t *ctr)
 Reset a counter.
 
SPHINXBASE_EXPORT void pctr_print (FILE *fp, pctr_t *ctr)
 Print a counter.
 
SPHINXBASE_EXPORT void pctr_increment (pctr_t *ctr, int32 inc)
 Increment a counter.
 
SPHINXBASE_EXPORT void pctr_free (pctr_t *ctr)
 Free the counter.
 
SPHINXBASE_EXPORT void ptmr_start (ptmr_t *tmr)
 Start timing using tmr.
 
SPHINXBASE_EXPORT void ptmr_stop (ptmr_t *tmr)
 Stop timing and accumulate tmr->{t_cpu, t_elapsed, t_tot_cpu, t_tot_elapsed}.
 
SPHINXBASE_EXPORT void ptmr_reset (ptmr_t *tmr)
 Reset tmr->{t_cpu, t_elapsed} to 0.0.
 
SPHINXBASE_EXPORT void ptmr_init (ptmr_t *tmr)
 Reset tmr->{t_cpu, t_elapsed, t_tot_cpu, t_tot_elapsed} to 0.0.
 
SPHINXBASE_EXPORT void ptmr_reset_all (ptmr_t *tmr)
 Reset t_cpu, t_elapsed of all timer modules in array tmr[] to 0.0.
 
SPHINXBASE_EXPORT void ptmr_print_all (FILE *fp, ptmr_t *tmr, float64 norm)
 Print t_cpu for all timer modules in tmr[], normalized by norm (i.e., t_cpu/norm).
 
SPHINXBASE_EXPORT int32 host_pclk (int32 dummy)
 Return the processor clock speed (in MHz); only available on some machines (Alphas).
 
SPHINXBASE_EXPORT int32 host_endian (void)
 

Detailed Description

Implementation of profiling, include counting , timing, cpu clock checking.

Currently, function host_endian is also in this function. It is not documented.

Definition in file profile.h.

Function Documentation

◆ host_endian()

SPHINXBASE_EXPORT int32 host_endian ( void )

Definition at line 301 of file profile.c.

◆ host_pclk()

SPHINXBASE_EXPORT int32 host_pclk ( int32 dummy)

Return the processor clock speed (in MHz); only available on some machines (Alphas).

The dummy argument can be any integer value.

◆ pctr_free()

SPHINXBASE_EXPORT void pctr_free ( pctr_t * ctr)

Free the counter.

Parameters
ctrA pointer of a counter

Definition at line 141 of file profile.c.

References ckd_free(), pctr_t::name, and pctr_free().

Referenced by pctr_free().

◆ pctr_increment()

SPHINXBASE_EXPORT void pctr_increment ( pctr_t * ctr,
int32 inc )

Increment a counter.

Parameters
ctrA pointer of a counter
incThe increment of the counter

Definition at line 127 of file profile.c.

References pctr_t::count, and pctr_increment().

Referenced by pctr_increment().

◆ pctr_new()

SPHINXBASE_EXPORT pctr_t * pctr_new ( char * name)

operations of pctr_t

Initialize a counter

Returns
an initialized counter
Parameters
nameThe name of the counter

Definition at line 108 of file profile.c.

References ckd_calloc, ckd_salloc, pctr_t::count, pctr_t::name, and pctr_new().

Referenced by pctr_new().

◆ pctr_print()

SPHINXBASE_EXPORT void pctr_print ( FILE * fp,
pctr_t * ctr )

Print a counter.

Parameters
fpA file pointer
ctrA pointer of a counter

Definition at line 134 of file profile.c.

References pctr_t::count, pctr_t::name, and pctr_print().

Referenced by pctr_print().

◆ pctr_reset()

SPHINXBASE_EXPORT void pctr_reset ( pctr_t * ctr)

Reset a counter.

Parameters
ctrA pointer of a counter

Definition at line 120 of file profile.c.

References pctr_t::count, and pctr_reset().

Referenced by pctr_reset().

◆ ptmr_init()

SPHINXBASE_EXPORT void ptmr_init ( ptmr_t * tmr)

Reset tmr->{t_cpu, t_elapsed, t_tot_cpu, t_tot_elapsed} to 0.0.

Parameters
tmrThe timer

Definition at line 272 of file profile.c.

References ptmr_t::t_cpu, ptmr_t::t_elapsed, ptmr_t::t_tot_cpu, and ptmr_t::t_tot_elapsed.

◆ ptmr_print_all()

SPHINXBASE_EXPORT void ptmr_print_all ( FILE * fp,
ptmr_t * tmr,
float64 norm )

Print t_cpu for all timer modules in tmr[], normalized by norm (i.e., t_cpu/norm).

The array should be terminated with a sentinel with .name = NULL.

Parameters
fpThe file pointer
tmrThe timer

Definition at line 290 of file profile.c.

References ptmr_t::name, and ptmr_t::t_cpu.

◆ ptmr_reset()

SPHINXBASE_EXPORT void ptmr_reset ( ptmr_t * tmr)

Reset tmr->{t_cpu, t_elapsed} to 0.0.

Parameters
tmrThe timer

Definition at line 264 of file profile.c.

References ptmr_t::t_cpu, and ptmr_t::t_elapsed.

Referenced by ptmr_reset_all().

◆ ptmr_reset_all()

SPHINXBASE_EXPORT void ptmr_reset_all ( ptmr_t * tmr)

Reset t_cpu, t_elapsed of all timer modules in array tmr[] to 0.0.

The array should be terminated with a sentinel with .name = NULL.

Parameters
tmrThe timer

Definition at line 282 of file profile.c.

References ptmr_t::name, and ptmr_reset().

◆ ptmr_start()

SPHINXBASE_EXPORT void ptmr_start ( ptmr_t * tmr)

Start timing using tmr.

Parameters
tmrThe timer

Definition at line 179 of file profile.c.

References ptmr_start(), ptmr_t::start_cpu, and ptmr_t::start_elapsed.

Referenced by ptmr_start().

◆ ptmr_stop()

SPHINXBASE_EXPORT void ptmr_stop ( ptmr_t * tmr)

Stop timing and accumulate tmr->{t_cpu, t_elapsed, t_tot_cpu, t_tot_elapsed}.

Parameters
tmrThe timer

Definition at line 216 of file profile.c.

References ptmr_t::start_cpu, ptmr_t::start_elapsed, ptmr_t::t_cpu, ptmr_t::t_elapsed, ptmr_t::t_tot_cpu, and ptmr_t::t_tot_elapsed.