PPL  1.2
Parma_Polyhedra_Library::Weight_Profiler Class Reference

#include <Weight_Profiler_defs.hh>

Public Member Functions

 Weight_Profiler (const char *file, int line, Weightwatch_Traits::Delta delta, double min_threshold=0, double max_threshold=0)
 
 ~Weight_Profiler ()
 
void output_stats ()
 
void end (unsigned int factor=1)
 

Static Public Member Functions

static void begin ()
 
static double tune_adjustment ()
 

Private Types

enum  { DISCARDED = 0, VALID = 1 }
 

Private Attributes

const char * file
 File of this profiling point. More...
 
int line
 Line of this profiling point. More...
 
Weightwatch_Traits::Delta delta
 Computational weight to be added at each iteration. More...
 
double min_threshold
 Times less than this value are discarded. More...
 
double max_threshold
 Times greater than this value are discarded. More...
 
struct {
   unsigned int   samples
 Number of collected samples. More...
 
   unsigned int   count
 Number of collected iterations. More...
 
   double   sum
 Sum of the measured times. More...
 
   double   squares_sum
 Sum of the squares of the measured times (to compute variance). More...
 
   double   min
 Minimum measured time. More...
 
   double   max
 Maximum measured time. More...
 
stat [2]
 Statistical data for samples (both DISCARDED and VALID) More...
 

Static Private Attributes

static struct timespec stamp
 Holds the time corresponding to last time begin() was called. More...
 
static double adjustment
 Time quantity used to adjust the elapsed times so as not to take into account the time spent by the measurement infrastructure. More...
 

Detailed Description

Definition at line 31 of file Weight_Profiler_defs.hh.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

Parma_Polyhedra_Library::Weight_Profiler::Weight_Profiler ( const char *  file,
int  line,
Weightwatch_Traits::Delta  delta,
double  min_threshold = 0,
double  max_threshold = 0 
)
inline

Definition at line 36 of file Weight_Profiler_defs.hh.

References stat.

39  : file(file), line(line), delta(delta),
41  for (int i = 0; i < 2; ++i) {
42  stat[i].samples = 0;
43  stat[i].count = 0;
44  stat[i].sum = 0;
45  stat[i].squares_sum = 0;
46  stat[i].min = 0;
47  stat[i].max = 0;
48  }
49  }
Weightwatch_Traits::Delta delta
Computational weight to be added at each iteration.
struct Parma_Polyhedra_Library::Weight_Profiler::@2 stat[2]
Statistical data for samples (both DISCARDED and VALID)
double min_threshold
Times less than this value are discarded.
double max_threshold
Times greater than this value are discarded.
const char * file
File of this profiling point.
int line
Line of this profiling point.
Parma_Polyhedra_Library::Weight_Profiler::~Weight_Profiler ( )
inline

Definition at line 51 of file Weight_Profiler_defs.hh.

References output_stats().

51  {
52  output_stats();
53  }

Member Function Documentation

static void Parma_Polyhedra_Library::Weight_Profiler::begin ( )
inlinestatic

Definition at line 57 of file Weight_Profiler_defs.hh.

References stamp.

Referenced by end().

57  {
58 #ifndef NDEBUG
59  int r = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &stamp);
60  assert(r >= 0);
61 #else
62  clock_gettime(CLOCK_THREAD_CPUTIME_ID, &stamp);
63 #endif
64  }
static struct timespec stamp
Holds the time corresponding to last time begin() was called.
void Parma_Polyhedra_Library::Weight_Profiler::end ( unsigned int  factor = 1)
inline

Definition at line 66 of file Weight_Profiler_defs.hh.

References adjustment, begin(), count, delta, DISCARDED, max, max_threshold, min, min_threshold, stamp, stat, VALID, and Parma_Polyhedra_Library::Weightwatch_Traits::weight.

66  {
69  struct timespec start = stamp;
70  begin();
71  double elapsed;
72  if (stamp.tv_nsec >= start.tv_nsec) {
73  elapsed = (stamp.tv_nsec - start.tv_nsec)
74  + (stamp.tv_sec - start.tv_sec) * 1e9;
75  }
76  else {
77  elapsed = (1000000000 - start.tv_nsec + stamp.tv_nsec )
78  + (stamp.tv_sec - start.tv_sec - 1) * 1e9;
79  }
80  elapsed -= adjustment;
81  double elapsed1 = elapsed / factor;
82  int i = (elapsed1 < min_threshold
83  || (max_threshold > 0 && elapsed1 > max_threshold))
84  ? DISCARDED
85  : VALID;
86  ++stat[i].samples;
87  if (stat[i].count == 0) {
88  stat[i].min = stat[i].max = elapsed1;
89  }
90  else if (stat[i].min > elapsed1) {
91  stat[i].min = elapsed1;
92  }
93  else if (stat[i].max < elapsed1) {
94  stat[i].max = elapsed1;
95  }
96  stat[i].sum += elapsed;
97  stat[i].squares_sum += elapsed * elapsed1;
98  stat[i].count += factor;
99  }
Weightwatch_Traits::Delta delta
Computational weight to be added at each iteration.
unsigned long long Threshold
The type used to specify thresholds for computational weight.
struct Parma_Polyhedra_Library::Weight_Profiler::@2 stat[2]
Statistical data for samples (both DISCARDED and VALID)
double min_threshold
Times less than this value are discarded.
double max_threshold
Times greater than this value are discarded.
static struct timespec stamp
Holds the time corresponding to last time begin() was called.
static Threshold weight
The current computational weight.
unsigned int count
Number of collected iterations.
static double adjustment
Time quantity used to adjust the elapsed times so as not to take into account the time spent by the m...
void Parma_Polyhedra_Library::Weight_Profiler::output_stats ( )

Referenced by ~Weight_Profiler().

static double Parma_Polyhedra_Library::Weight_Profiler::tune_adjustment ( )
static

Member Data Documentation

double Parma_Polyhedra_Library::Weight_Profiler::adjustment
staticprivate

Time quantity used to adjust the elapsed times so as not to take into account the time spent by the measurement infrastructure.

Definition at line 152 of file Weight_Profiler_defs.hh.

Referenced by end().

unsigned int Parma_Polyhedra_Library::Weight_Profiler::count

Number of collected iterations.

Note
Multiple iterations are possibly collected for each sample.

Definition at line 130 of file Weight_Profiler_defs.hh.

Referenced by end().

Weightwatch_Traits::Delta Parma_Polyhedra_Library::Weight_Profiler::delta
private

Computational weight to be added at each iteration.

Definition at line 111 of file Weight_Profiler_defs.hh.

Referenced by end().

const char* Parma_Polyhedra_Library::Weight_Profiler::file
private

File of this profiling point.

Definition at line 105 of file Weight_Profiler_defs.hh.

int Parma_Polyhedra_Library::Weight_Profiler::line
private

Line of this profiling point.

Definition at line 108 of file Weight_Profiler_defs.hh.

double Parma_Polyhedra_Library::Weight_Profiler::max

Maximum measured time.

Definition at line 142 of file Weight_Profiler_defs.hh.

Referenced by end().

double Parma_Polyhedra_Library::Weight_Profiler::max_threshold
private

Times greater than this value are discarded.

Definition at line 117 of file Weight_Profiler_defs.hh.

Referenced by end().

double Parma_Polyhedra_Library::Weight_Profiler::min

Minimum measured time.

Definition at line 139 of file Weight_Profiler_defs.hh.

Referenced by end().

double Parma_Polyhedra_Library::Weight_Profiler::min_threshold
private

Times less than this value are discarded.

Definition at line 114 of file Weight_Profiler_defs.hh.

Referenced by end().

unsigned int Parma_Polyhedra_Library::Weight_Profiler::samples

Number of collected samples.

Definition at line 122 of file Weight_Profiler_defs.hh.

double Parma_Polyhedra_Library::Weight_Profiler::squares_sum

Sum of the squares of the measured times (to compute variance).

Definition at line 136 of file Weight_Profiler_defs.hh.

struct timespec Parma_Polyhedra_Library::Weight_Profiler::stamp
staticprivate

Holds the time corresponding to last time begin() was called.

Definition at line 146 of file Weight_Profiler_defs.hh.

Referenced by begin(), and end().

struct { ... } Parma_Polyhedra_Library::Weight_Profiler::stat[2]

Statistical data for samples (both DISCARDED and VALID)

Referenced by end(), and Weight_Profiler().

double Parma_Polyhedra_Library::Weight_Profiler::sum

Sum of the measured times.

Definition at line 133 of file Weight_Profiler_defs.hh.


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