-condor_utils has classes designed to make measuring and publishing statistics about the performance of code easy. The classes are defined in =generic_stats.h= +=condor_utils= has classes designed to make measuring and publishing statistics about the performance of code easy. The classes are defined in =generic_stats.h= This consists of a set of simple templatized classes that you add as member variables to your code, or to a helper class or structure. The most commonly used of these is the =stats_entry_recent= class. This class keeps track of a total value, and also uses a ring buffer to keep track of recent values. {subsection: Adding statistics values to an existing collection} -To add a statistics value where there is already an existing collection of values +To add a statistics value where there is already an existing collection of values, do the following: -*: Declare a member of type =stats_entry_xxx= and add it to the stats collection class. the most common type is =stats_entry_recent=. The collection is a member of type {quote: StatisticsPool} and is usually -a named Pool +*: Declare a member of type =stats_entry_xxx= and add it to the stats collection class. the most common type is =stats_entry_recent=. The collection is a member of type _{quote: StatisticsPool}_ and is usually +named _Pool_ *: Set or increment the variable in the code to be measured. {subsection: Adding a statistics value when there isn't a collection} @@ -18,6 +18,7 @@ *: Periodically call the =Advance= or =AdvanceBy= method to rotate the recent buffer *: call the =Publish= method to write the value as a {quote: ClassAd} attribute. +Below is code suitable for creating an object that keeps track of times. {code} class MyObject { @@ -44,7 +45,7 @@ last_rotate_time = begintime - (delta % time_quantum); } - ... do some work + // ... do some work // accumulate statistics data myObjectRuntime += time(NULL) - begintime; @@ -85,7 +86,7 @@ *:: use =stats_recent_counter_timer= for probes that accumulate runtime *:: use =stats_entry_probe<type>= for probes that publish min,max,avg,stdev{linebreak} *:: use =stats_entry_recent<Probe>= for probes that publish min,max,avg,stdev and also keep a recent buffer of the same.{linebreak} -*: give your stats class methods for Init, Clear, Tick and Publish, and have those methods call the corresponding methods on the {quote: StatisticsPool} member +*: give your stats class methods for =Init=, =Clear=, =Tick=, and =Publish=, and have those methods call the corresponding methods on the member variable of type _{quote: StatisticsPool}_. {code} class MyStats { @@ -111,7 +112,7 @@ } MyStats; {endcode} -Then in your cpp file for the =MyStats= class +Then, in your C++ source file for the =MyStats= class: {code} void MyStats::Init()