Psi4
Classes | Namespaces | Macros | Functions | Variables

Obtain user and system timings for blocks of codeTIMER.CC: These functions allow one to obtain user and system timings for arbitrary blocks of code. If a code block is called repeatedly during the course of program execution, the timer functions will report the block's cumulative execution time and the number of calls. In addition, one may time multiple code blocks simultaneously, and even ``overlap'' timers. Timing data is written to the file "timer.dat" at the end of timer execution, i.e., when timer_done() is called. More...

#include <cstdio>
#include <cstdlib>
#include <unistd.h>
#include <cstring>
#include <ctime>
#include <sys/param.h>
#include <sys/times.h>
#include "psi4/libciomr/libciomr.h"
#include "psi4/psifiles.h"
#include "psi4/psi4-dec.h"
#include "psi4/libparallel/ParallelPrinter.h"

Classes

struct  psi::timer
 

Namespaces

 psi
 Rotate a set of vectors around an arbitrary axis Vectors are rows of input matrix.
 

Macros

#define HZ   60
 
#define TIMER_KEYLEN   128
 
#define TIMER_OFF   0
 
#define TIMER_ON   1
 

Functions

void psi::timer_init (void)
 
void psi::timer_done (void)
 
struct timer * psi::timer_scan (const char *key)
 
struct timer * psi::timer_last (void)
 
void psi::timer_on (const char *key)
 
double psi::timer_nsdiff (struct timeval &endt, struct timeval &begint)
 
void psi::timer_off (const char *key)
 

Variables

struct timer * psi::global_timer
 
time_t psi::timer_start
 
time_t psi::timer_end
 

Detailed Description

Obtain user and system timings for blocks of code

TIMER.CC: These functions allow one to obtain user and system timings for arbitrary blocks of code. If a code block is called repeatedly during the course of program execution, the timer functions will report the block's cumulative execution time and the number of calls. In addition, one may time multiple code blocks simultaneously, and even ``overlap'' timers. Timing data is written to the file "timer.dat" at the end of timer execution, i.e., when timer_done() is called.

To use the timer functions defined here:

(1) Initialize the linked list of timers at the beginning of your program: timer_init();

(2) Start a timer at the start of the block of code: timer_on("My Timer");

(3) Stop the timer at the end of the block: timer_off("My Timer");

(4) When all timer calls are complete, dump the linked list of timing data to the output file, "timer.dat": timer_done();

NB this code uses system functions ctime(), time(), and times(), which may not quite be standard on all machines.

T. Daniel Crawford, August 1999.

Modified to use timeval structures for the module wall times, getting nanosecond precision on cumulated wall time instead of second. Useful to time integral computations where there can be millions to billion calls to functions.

J. F. Gonthier, February 2016

Macro Definition Documentation

#define HZ   60
#define TIMER_KEYLEN   128
#define TIMER_OFF   0
#define TIMER_ON   1