yosys-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PerformanceTimer Struct Reference

#include <log.h>

Public Member Functions

 PerformanceTimer ()
 
void reset ()
 
void begin ()
 
void end ()
 
float sec () const
 

Static Public Member Functions

static int64_t query ()
 

Data Fields

int64_t total_ns
 

Detailed Description

Definition at line 142 of file log.h.

Constructor & Destructor Documentation

PerformanceTimer::PerformanceTimer ( )
inline

Definition at line 147 of file log.h.

147  {
148  total_ns = 0;
149  }
int64_t total_ns
Definition: log.h:145

Member Function Documentation

void PerformanceTimer::begin ( )
inline

Definition at line 177 of file log.h.

177  {
178  total_ns -= query();
179  }
static int64_t query()
Definition: log.h:151
int64_t total_ns
Definition: log.h:145

+ Here is the call graph for this function:

void PerformanceTimer::end ( )
inline

Definition at line 181 of file log.h.

181  {
182  total_ns += query();
183  }
static int64_t query()
Definition: log.h:151
int64_t total_ns
Definition: log.h:145

+ Here is the call graph for this function:

static int64_t PerformanceTimer::query ( )
inlinestatic

Definition at line 151 of file log.h.

151  {
152 #if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
153  struct timespec ts;
154  clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
155  return int64_t(ts.tv_sec)*1000000000 + ts.tv_nsec;
156 #elif defined(RUSAGE_SELF)
157  struct rusage rusage;
158  int64_t t;
159  if (getrusage(RUSAGE_SELF, &rusage) == -1) {
160  log_cmd_error("getrusage failed!\n");
161  log_abort();
162  }
163  t = 1000000000ULL * (int64_t) rusage.ru_utime.tv_sec + (int64_t) rusage.ru_utime.tv_usec * 1000ULL;
164  t += 1000000000ULL * (int64_t) rusage.ru_stime.tv_sec + (int64_t) rusage.ru_stime.tv_usec * 1000ULL;
165  return t;
166 #elif _WIN32
167  return 0;
168 #else
169  #error Dont know how to measure per-process CPU time. Need alternative method (times()/clocks()/gettimeofday()?).
170 #endif
171  }
#define log_abort()
Definition: log.h:84
YS_NORETURN void log_cmd_error(const char *format,...) YS_ATTRIBUTE(format(printf

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void PerformanceTimer::reset ( )
inline

Definition at line 173 of file log.h.

173  {
174  total_ns = 0;
175  }
int64_t total_ns
Definition: log.h:145
float PerformanceTimer::sec ( ) const
inline

Definition at line 185 of file log.h.

185  {
186  return total_ns * 1e-9f;
187  }
int64_t total_ns
Definition: log.h:145

+ Here is the caller graph for this function:

Field Documentation

int64_t PerformanceTimer::total_ns

Definition at line 145 of file log.h.


The documentation for this struct was generated from the following file: