dlvhex  2.5.0
benchmark::simple::BenchmarkController Class Reference

Supports benchmarking of different components of dlvhex. More...

#include <include/dlvhex2/Benchmarking.h>

Collaboration diagram for benchmark::simple::BenchmarkController:

Data Structures

struct  Stat
 Information about a single benchmark value. More...

Public Member Functions

std::ostream & printInSecs (std::ostream &o, const Duration &d, int width=0) const
 Prints a value in seconds.
std::string count (const std::string &identifier, int width=0) const
 Outputs a count value.
std::string duration (const std::string &identifier, int width=0) const
 Outputs a duration value.
void printInformation (const Stat &st)
 Print information about stat.
void printInformationContinous (Stat &st, const Duration &dur)
 Print continuous information about stat.
 ~BenchmarkController ()
 Destructor.
void setOutput (std::ostream *o)
 Sets the output stream for printing.
void setPrintInterval (Count skip)
 Amount of accumulated output (default: each call).
ID getInstrumentationID (const std::string &name)
 Get ID or register new one.
std::ostream & printCount (std::ostream &out, ID id)
 Print only count of ID.
std::ostream & printDuration (std::ostream &out, ID id)
 Print only duration of ID.
const StatgetStat (ID id) const
 Retrieve Stat of id.
void suspend ()
 Stop all benchmarking temporarily.
void resume ()
 Resume all benchmarking.
void start (ID id)
 Start a benchmark.
void stop (ID id, bool count=true)
 Stop and record elapsed time, print stats.
void count (ID id, Count increment=1)
 Record count (no time), print stats.
void invalidate (ID id)
 Stop and do not record anything.
void snapshot (ID id, ID intoID)
 Copy data from one id to another id and call stop() on that other id.
void snapshot (const std::string &fromstr, const std::string &tostr)
 Copy data from one benchmark to another and call stop() on that other benchmark.

Static Public Member Functions

static BenchmarkControllerInstance ()
 Singleton access.
static void finish ()
 Delete the singleton instance.

Private Member Functions

 BenchmarkController ()
 Constructor.

Private Attributes

ID myID
 ID of the benchmark which measures the BenchmarkController itself.
ID maxID
 ID to be used for the next benchmark registered.
std::vector< Statinstrumentations
 Vector of benchmark statistics.
std::map< std::string, IDname2id
 Map from benchmark names to IDs.
std::ostream * output
 Output stream to be used.
Count printSkip
 Counter for skipping benchmark output.
boost::mutex mutex
 Mutex for multithreading access.
unsigned sus
 Level of suspending benchmarking (0 = not suspended).

Detailed Description

Supports benchmarking of different components of dlvhex.

Definition at line 181 of file Benchmarking.h.


Constructor & Destructor Documentation

Constructor.

Init, display start of benchmarking.

Definition at line 59 of file Benchmarking.cpp.

References getInstrumentationID(), myID, and start().

Referenced by Instance().


Member Function Documentation

std::string benchmark::simple::BenchmarkController::count ( const std::string &  identifier,
int  width = 0 
) const

Outputs a count value.

Parameters:
identifierBenchmark value to output.
widthSee BenchmarkController::printInSecs.

Definition at line 144 of file Benchmarking.cpp.

References benchmark::nestingAware::NestingAwareController::Stat::count, getStat(), name2id, and sus.

void benchmark::simple::BenchmarkController::count ( ID  id,
Count  increment = 1 
) [inline]

Record count (no time), print stats.

Parameters:
idID of the benchmark to count.
incrementIncrement the count by this value.

Definition at line 476 of file Benchmarking.h.

References benchmark::simple::BenchmarkController::Stat::count, instrumentations, mutex, printInformationContinous(), benchmark::simple::BenchmarkController::Stat::prints, and sus.

std::string benchmark::simple::BenchmarkController::duration ( const std::string &  identifier,
int  width = 0 
) const

Outputs a duration value.

Parameters:
identifierBenchmark value to output.
widthSee BenchmarkController::printInSecs.

Definition at line 156 of file Benchmarking.cpp.

References getStat(), name2id, printInSecs(), and sus.

Delete the singleton instance.

Causes destructor to be called.

Definition at line 88 of file Benchmarking.cpp.

Get ID or register new one.

Parameters:
nameIdentifier.
Returns:
ID of name.

Definition at line 111 of file Benchmarking.cpp.

References instrumentations, maxID, mutex, and name2id.

Referenced by BenchmarkController(), resume(), snapshot(), and suspend().

Retrieve Stat of id.

Parameters:
idID whose Stat is to be retrieved.
Returns:
Stat of id.

Definition at line 283 of file Benchmarking.h.

Referenced by count(), and duration().

Singleton access.

Returns:
Single instance of BenchmarkController.

Definition at line 94 of file Benchmarking.cpp.

References BenchmarkController().

Stop and do not record anything.

If not running, do not do anything.

Parameters:
idID of the benchmark to stop.

Definition at line 169 of file Benchmarking.cpp.

References instrumentations, mutex, benchmark::simple::BenchmarkController::Stat::running, and sus.

std::ostream & benchmark::simple::BenchmarkController::printCount ( std::ostream &  out,
ID  id 
) [inline]

Print only count of ID.

Parameters:
outOutput stream.
idID whose information is to be printed.
Returns:
out.

Definition at line 402 of file Benchmarking.h.

References benchmark::simple::BenchmarkController::Stat::count, instrumentations, and mutex.

std::ostream & benchmark::simple::BenchmarkController::printDuration ( std::ostream &  out,
ID  id 
) [inline]

Print only duration of ID.

Parameters:
outOutput stream.
idID whose duration is to be printed.

Definition at line 408 of file Benchmarking.h.

References benchmark::simple::BenchmarkController::Stat::duration, instrumentations, mutex, and printInSecs().

std::ostream & benchmark::simple::BenchmarkController::printInSecs ( std::ostream &  o,
const Duration d,
int  width = 0 
) const [inline]

Prints a value in seconds.

Parameters:
oStream to print to.
dDuration value.
widthWidth of the output in characters for alignment.

Definition at line 361 of file Benchmarking.h.

Referenced by duration(), printDuration(), printInformation(), and printInformationContinous().

Resume all benchmarking.

Definition at line 135 of file Benchmarking.cpp.

References getInstrumentationID(), mutex, myID, stop(), and sus.

Sets the output stream for printing.

Parameters:
oOutput stream to use in the following.

Definition at line 101 of file Benchmarking.cpp.

References output.

Amount of accumulated output (default: each call).

Parameters:
skipInterval.

Definition at line 106 of file Benchmarking.cpp.

References printSkip.

Copy data from one id to another id and call stop() on that other id.

E.g. do this for several interesting benchmarks at first model.

Parameters:
idID to copy.
intoIDID to copy id into.

Definition at line 180 of file Benchmarking.cpp.

References benchmark::simple::BenchmarkController::Stat::count, benchmark::simple::BenchmarkController::Stat::duration, instrumentations, mutex, benchmark::simple::BenchmarkController::Stat::running, benchmark::simple::BenchmarkController::Stat::start, stop(), and sus.

Referenced by snapshot().

void benchmark::simple::BenchmarkController::snapshot ( const std::string &  fromstr,
const std::string &  tostr 
)

Copy data from one benchmark to another and call stop() on that other benchmark.

E.g. do this for several interesting benchmarks at first model.

Parameters:
fromstrBenchmark to copy.
tostrBenchmark to copy fromstr into.

Definition at line 199 of file Benchmarking.cpp.

References getInstrumentationID(), snapshot(), and sus.

void benchmark::simple::BenchmarkController::stop ( ID  id,
bool  count = true 
) [inline]

Stop and record elapsed time, print stats.

Parameters:
idID of the benchmark to stop.
countIf count is false, stop time but do not count (for suspending timer).

Definition at line 454 of file Benchmarking.h.

References benchmark::simple::BenchmarkController::Stat::count, benchmark::simple::BenchmarkController::Stat::duration, instrumentations, benchmark::simple::BenchmarkController::Stat::level, mutex, printInformationContinous(), benchmark::simple::BenchmarkController::Stat::running, benchmark::simple::BenchmarkController::Stat::start, and sus.

Referenced by resume(), and snapshot().

Stop all benchmarking temporarily.

Definition at line 126 of file Benchmarking.cpp.

References getInstrumentationID(), mutex, myID, start(), and sus.


Field Documentation

ID to be used for the next benchmark registered.

Definition at line 343 of file Benchmarking.h.

Referenced by getInstrumentationID().

Mutex for multithreading access.

Definition at line 355 of file Benchmarking.h.

Referenced by count(), getInstrumentationID(), invalidate(), printCount(), printDuration(), resume(), snapshot(), start(), stop(), and suspend().

ID of the benchmark which measures the BenchmarkController itself.

Definition at line 341 of file Benchmarking.h.

Referenced by BenchmarkController(), resume(), suspend(), and ~BenchmarkController().

std::map<std::string, ID> benchmark::simple::BenchmarkController::name2id [private]

Map from benchmark names to IDs.

Definition at line 347 of file Benchmarking.h.

Referenced by count(), duration(), and getInstrumentationID().

Output stream to be used.

Definition at line 350 of file Benchmarking.h.

Referenced by printInformation(), printInformationContinous(), and setOutput().

Counter for skipping benchmark output.

Definition at line 352 of file Benchmarking.h.

Referenced by printInformationContinous(), and setPrintInterval().

Level of suspending benchmarking (0 = not suspended).

Definition at line 357 of file Benchmarking.h.

Referenced by count(), duration(), invalidate(), resume(), snapshot(), start(), stop(), and suspend().


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