GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-df949ca623
rtimer.h File Reference
#include <sys/time.h>
#include <sys/resource.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
Include dependency graph for rtimer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Rtimer
 

Macros

#define rt_start(rt)
 
#define rt_stop(rt)
 
#define rt_u_useconds(rt)
 
#define rt_s_useconds(rt)
 
#define rt_w_useconds(rt)
 
#define rt_zero(rt)   bzero(&(rt), sizeof(Rtimer));
 
#define rt_seconds(rt)   (rt_w_useconds(rt) / 1000000)
 
#define rt_sprint(buf, rt)   rt_sprint_safe(buf, rt)
 

Functions

char * rt_sprint_safe (char *buf, Rtimer rt)
 

Macro Definition Documentation

◆ rt_s_useconds

#define rt_s_useconds (   rt)
Value:
(((double)rt.rut2.ru_stime.tv_usec + \
(double)rt.rut2.ru_stime.tv_sec * 1000000) - \
((double)rt.rut1.ru_stime.tv_usec + \
(double)rt.rut1.ru_stime.tv_sec * 1000000))

Definition at line 103 of file rtimer.h.

◆ rt_seconds

#define rt_seconds (   rt)    (rt_w_useconds(rt) / 1000000)

Definition at line 119 of file rtimer.h.

◆ rt_sprint

#define rt_sprint (   buf,
  rt 
)    rt_sprint_safe(buf, rt)

Definition at line 121 of file rtimer.h.

◆ rt_start

#define rt_start (   rt)
Value:
if ((getrusage(RUSAGE_SELF, &rt.rut1) < 0) || \
(gettimeofday(&(rt.tv1), NULL) < 0)) { \
perror("rusage/gettimeofday"); \
exit(1); \
}
#define NULL
Definition: ccmath.h:32

Definition at line 82 of file rtimer.h.

◆ rt_stop

#define rt_stop (   rt)
Value:
if ((getrusage(RUSAGE_SELF, &rt.rut2) < 0) || \
(gettimeofday(&(rt.tv2), NULL) < 0)) { \
perror("rusage/gettimeofday"); \
exit(1); \
}

Definition at line 90 of file rtimer.h.

◆ rt_u_useconds

#define rt_u_useconds (   rt)
Value:
(((double)rt.rut2.ru_utime.tv_usec + \
(double)rt.rut2.ru_utime.tv_sec * 1000000) - \
((double)rt.rut1.ru_utime.tv_usec + \
(double)rt.rut1.ru_utime.tv_sec * 1000000))

Definition at line 97 of file rtimer.h.

◆ rt_w_useconds

#define rt_w_useconds (   rt)
Value:
(((double)rt.tv2.tv_usec + (double)rt.tv2.tv_sec * 1000000) - \
((double)rt.tv1.tv_usec + (double)rt.tv1.tv_sec * 1000000))

Definition at line 109 of file rtimer.h.

◆ rt_zero

#define rt_zero (   rt)    bzero(&(rt), sizeof(Rtimer));

Definition at line 117 of file rtimer.h.

Function Documentation

◆ rt_sprint_safe()

char* rt_sprint_safe ( char *  buf,
Rtimer  rt 
)

Definition at line 45 of file rtimer.cpp.

References BUFMAX, rt_s_useconds, rt_u_useconds, and rt_w_useconds.