Sampler.h

class Cubism::Util::Sampler

Sample collector.

Used to collect time samples (by default) for a code section that is enclosed by the seedSample() and collectSample() methods. Used for profiling.

Subclassed by Cubism::Util::Histogram, Cubism::Util::Profiler

Public Functions

inline explicit Sampler(const bool active = true)

Default constructor.

Parameters
  • active: Activator switch

inline void seedSample()

Seed new sample.

Pushes a new timer on the stack.

inline void collectSample(const std::string &name)

Collect a sample.

Pops the top timer off the stack and collects the measured time sample for the given name.

Parameters
  • name: Name of the collected sample

inline void popLast(const std::string &name)

Pop a sample.

Pops the last (most recent) sample of name from the sample container.

Parameters
  • name: Name of the sample

inline void append(const Sampler &s)

Append samples.

Inserts all samples from s into this sampler.

Parameters
  • s: Sampler to take samples from

inline void appendSample(const std::string &name, const double samp)

Append single sample.

Appends the sample samp to the list of samples with name.

Parameters
  • name: Name of the sample

  • samp: Sample value

inline void insert(const std::string &name, const std::vector<double> &data)

Insert vector of samples.

Parameters
  • name: Name of the samples

  • data: Vector of samples to be inserted

inline void addTo(const std::string &addto, const std::vector<double> &yours)

Perform addition with sample values.

The number of samples in yours must be the same as the number of samples in addto, otherwise a runtime error is thrown.

Parameters
  • addto: Name of samples to be added to

  • yours: Vector of samples to be arithmetically added

inline void subtractFrom(const std::string &from, const std::vector<double> &yours)

Perform subtraction with sample values.

The number of samples in yours must be the same as the number of samples in from, otherwise a runtime error is thrown.

Parameters
  • from: Name of samples to be subtracted from (minuend)

  • yours: Vector of samples to be arithmetically subtracted (subtrahend)

inline const SampleMap &getSamples() const

Get the sample container.

Return

const reference to sample map

inline void clear()

Clear the sampler data.

After this method is called the sampler will contain zero samples.