dlvhex  2.5.0
benchmark::nestingAware::NestingAwareController Class Reference

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

#include <include/dlvhex2/Benchmarking.h>

Collaboration diagram for benchmark::nestingAware::NestingAwareController:

Data Structures

struct  Current
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.
 ~NestingAwareController ()
 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 NestingAwareControllerInstance ()
 Singleton access.
static void finish ()
 Delete the singleton instance.

Private Member Functions

 NestingAwareController ()
 Constructor.

Private Attributes

ID myID
 ID of the benchmark which measures the NestingAwareController 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::vector< Currentcurrent
 Stack of currently running instrumentations.
Duration printInterval
 Interval for printing continuous benchmarks.
std::ostream * output
 Output stream to be used.
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 492 of file Benchmarking.h.


Constructor & Destructor Documentation

Constructor.

Init, display start of benchmarking.

Definition at line 220 of file Benchmarking.cpp.

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

Referenced by Instance().


Member Function Documentation

std::string benchmark::nestingAware::NestingAwareController::count ( const std::string &  identifier,
int  width = 0 
) const

Outputs a count value.

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

Definition at line 368 of file Benchmarking.cpp.

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

void benchmark::nestingAware::NestingAwareController::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 803 of file Benchmarking.h.

References benchmark::nestingAware::NestingAwareController::Stat::count, instrumentations, mutex, and printInformationContinous().

std::string benchmark::nestingAware::NestingAwareController::duration ( const std::string &  identifier,
int  width = 0 
) const

Outputs a duration value.

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

Definition at line 379 of file Benchmarking.cpp.

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

Referenced by PostProcessState::postProcess().

Delete the singleton instance.

Causes destructor to be called.

Definition at line 311 of file Benchmarking.cpp.

Referenced by main(), and signal_handler().

Get ID or register new one.

Parameters:
nameIdentifier.
Returns:
ID of name.

Definition at line 335 of file Benchmarking.cpp.

References instrumentations, maxID, mutex, name2id, and printInterval.

Referenced by NestingAwareController(), PostProcessState::postProcess(), resume(), snapshot(), and suspend().

Retrieve Stat of id.

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

Definition at line 600 of file Benchmarking.h.

Referenced by count(), duration(), and PostProcessState::postProcess().

Singleton access.

Returns:
Single instance of NestingAwareController.

Definition at line 317 of file Benchmarking.cpp.

References NestingAwareController().

Referenced by main(), and PostProcessState::postProcess().

Stop and do not record anything.

If not running, do not do anything.

Parameters:
idID of the benchmark to stop.

Definition at line 392 of file Benchmarking.cpp.

References current, and start().

std::ostream & benchmark::nestingAware::NestingAwareController::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 700 of file Benchmarking.h.

References benchmark::nestingAware::NestingAwareController::Stat::count, instrumentations, and mutex.

std::ostream & benchmark::nestingAware::NestingAwareController::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 706 of file Benchmarking.h.

References benchmark::nestingAware::NestingAwareController::Stat::duration, instrumentations, mutex, and printInSecs().

Referenced by main().

std::ostream & benchmark::nestingAware::NestingAwareController::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 680 of file Benchmarking.h.

Referenced by duration(), PostProcessState::postProcess(), printDuration(), printInformation(), printInformationContinous(), and ~NestingAwareController().

Resume all benchmarking.

Definition at line 359 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 324 of file Benchmarking.cpp.

References output.

Referenced by main().

Amount of accumulated output (default: each call).

Parameters:
skipInterval.

Definition at line 329 of file Benchmarking.cpp.

Referenced by main().

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 407 of file Benchmarking.cpp.

References benchmark::nestingAware::NestingAwareController::Stat::count, current, benchmark::nestingAware::NestingAwareController::Stat::duration, instrumentations, mutex, and benchmark::nestingAware::NestingAwareController::Stat::pureDuration.

Referenced by snapshot().

void benchmark::nestingAware::NestingAwareController::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 451 of file Benchmarking.cpp.

References getInstrumentationID(), and snapshot().

Stop all benchmarking temporarily.

Definition at line 350 of file Benchmarking.cpp.

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


Field Documentation

Stack of currently running instrumentations.

Definition at line 666 of file Benchmarking.h.

Referenced by invalidate(), snapshot(), start(), stop(), and ~NestingAwareController().

ID to be used for the next benchmark registered.

Definition at line 660 of file Benchmarking.h.

Referenced by getInstrumentationID().

Mutex for multithreading access.

Definition at line 674 of file Benchmarking.h.

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

ID of the benchmark which measures the NestingAwareController itself.

Definition at line 658 of file Benchmarking.h.

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

Map from benchmark names to IDs.

Definition at line 664 of file Benchmarking.h.

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

Output stream to be used.

Definition at line 671 of file Benchmarking.h.

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

Interval for printing continuous benchmarks.

Definition at line 669 of file Benchmarking.h.

Referenced by getInstrumentationID(), and printInformationContinous().

Level of suspending benchmarking (0 = not suspended).

Definition at line 676 of file Benchmarking.h.

Referenced by resume(), and suspend().


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