dlvhex
2.5.0
|
Supports benchmarking of different components of dlvhex. More...
#include <include/dlvhex2/Benchmarking.h>
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 Stat & | getStat (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 NestingAwareController & | Instance () |
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< Stat > | instrumentations |
Vector of benchmark statistics. | |
std::map< std::string, ID > | name2id |
Map from benchmark names to IDs. | |
std::vector< Current > | current |
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). |
Supports benchmarking of different components of dlvhex.
Definition at line 492 of file Benchmarking.h.
Destructor.
Output benchmark results, destruct.
Definition at line 229 of file Benchmarking.cpp.
References benchmark::nestingAware::NestingAwareController::Stat::count, current, benchmark::nestingAware::NestingAwareController::Stat::duration, instrumentations, myID, benchmark::nestingAware::NestingAwareController::Stat::name, output, printInSecs(), and benchmark::nestingAware::NestingAwareController::Stat::pureDuration.
Constructor.
Init, display start of benchmarking.
Definition at line 220 of file Benchmarking.cpp.
References getInstrumentationID(), myID, and start().
Referenced by Instance().
std::string benchmark::nestingAware::NestingAwareController::count | ( | const std::string & | identifier, |
int | width = 0 |
||
) | const |
Outputs a count value.
identifier | Benchmark value to output. |
width | See 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.
id | ID of the benchmark to count. |
increment | Increment 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.
identifier | Benchmark value to output. |
width | See NestingAwareController::printInSecs. |
Definition at line 379 of file Benchmarking.cpp.
References getStat(), name2id, and printInSecs().
Referenced by PostProcessState::postProcess().
void benchmark::nestingAware::NestingAwareController::finish | ( | ) | [static] |
Delete the singleton instance.
Causes destructor to be called.
Definition at line 311 of file Benchmarking.cpp.
Referenced by main(), and signal_handler().
ID benchmark::nestingAware::NestingAwareController::getInstrumentationID | ( | const std::string & | name | ) |
Get ID or register new one.
name | Identifier. |
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().
const Stat& benchmark::nestingAware::NestingAwareController::getStat | ( | ID | id | ) | const [inline] |
Retrieve Stat of id
.
id
. Definition at line 600 of file Benchmarking.h.
Referenced by count(), duration(), and PostProcessState::postProcess().
Singleton access.
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.
id | ID of the benchmark to stop. |
Definition at line 392 of file Benchmarking.cpp.
std::ostream & benchmark::nestingAware::NestingAwareController::printCount | ( | std::ostream & | out, |
ID | id | ||
) | [inline] |
Print only count of ID.
out | Output stream. |
id | ID whose information is to be printed. |
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.
out | Output stream. |
id | ID 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().
void benchmark::nestingAware::NestingAwareController::printInformation | ( | const Stat & | st | ) |
Print information about stat.
st | Identifies a benchmark value. |
Definition at line 432 of file Benchmarking.cpp.
References benchmark::nestingAware::NestingAwareController::Stat::count, benchmark::nestingAware::NestingAwareController::Stat::duration, benchmark::nestingAware::NestingAwareController::Stat::name, output, printInSecs(), and benchmark::nestingAware::NestingAwareController::Stat::pureDuration.
void benchmark::nestingAware::NestingAwareController::printInformationContinous | ( | Stat & | st, |
const Duration & | dur | ||
) | [inline] |
Print continuous information about stat.
st | Identifies a benchmark value. |
Definition at line 714 of file Benchmarking.h.
References benchmark::nestingAware::NestingAwareController::Stat::count, benchmark::nestingAware::NestingAwareController::Stat::duration, benchmark::nestingAware::NestingAwareController::Stat::name, benchmark::nestingAware::NestingAwareController::Stat::nextPrint, output, printInSecs(), printInterval, and benchmark::nestingAware::NestingAwareController::Stat::pureDuration.
std::ostream & benchmark::nestingAware::NestingAwareController::printInSecs | ( | std::ostream & | o, |
const Duration & | d, | ||
int | width = 0 |
||
) | const [inline] |
Prints a value in seconds.
o | Stream to print to. |
d | Duration value. |
width | Width 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.
void benchmark::nestingAware::NestingAwareController::setOutput | ( | std::ostream * | o | ) |
Sets the output stream for printing.
o | Output 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).
skip | Interval. |
Definition at line 329 of file Benchmarking.cpp.
Referenced by main().
void benchmark::nestingAware::NestingAwareController::snapshot | ( | ID | id, |
ID | intoID | ||
) |
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.
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.
fromstr | Benchmark to copy. |
tostr | Benchmark to copy fromstr into. |
Definition at line 451 of file Benchmarking.cpp.
References getInstrumentationID(), and snapshot().
void benchmark::nestingAware::NestingAwareController::start | ( | ID | id | ) | [inline] |
Start a benchmark.
id | ID of the benchmark to start. |
Definition at line 734 of file Benchmarking.h.
References current, benchmark::nestingAware::NestingAwareController::Current::firststart, instrumentations, benchmark::nestingAware::NestingAwareController::Stat::level, mutex, benchmark::nestingAware::NestingAwareController::Stat::pureDuration, benchmark::nestingAware::NestingAwareController::Current::start, and benchmark::nestingAware::NestingAwareController::Current::which.
Referenced by invalidate(), NestingAwareController(), and suspend().
void benchmark::nestingAware::NestingAwareController::stop | ( | ID | id, |
bool | count = true |
||
) | [inline] |
Stop and record elapsed time, print stats.
id | ID of the benchmark to stop. |
count | If count is false, stop time but do not count (for suspending timer). |
Definition at line 757 of file Benchmarking.h.
References benchmark::nestingAware::NestingAwareController::Stat::count, current, benchmark::nestingAware::NestingAwareController::Stat::duration, benchmark::nestingAware::NestingAwareController::Current::firststart, instrumentations, benchmark::nestingAware::NestingAwareController::Stat::level, mutex, benchmark::nestingAware::NestingAwareController::Stat::name, printInformationContinous(), benchmark::nestingAware::NestingAwareController::Stat::pureDuration, benchmark::nestingAware::NestingAwareController::Current::start, and benchmark::nestingAware::NestingAwareController::Current::which.
Referenced by PostProcessState::postProcess(), and resume().
Stop all benchmarking temporarily.
Definition at line 350 of file Benchmarking.cpp.
References getInstrumentationID(), mutex, myID, start(), and sus.
std::vector<Current> benchmark::nestingAware::NestingAwareController::current [private] |
Stack of currently running instrumentations.
Definition at line 666 of file Benchmarking.h.
Referenced by invalidate(), snapshot(), start(), stop(), and ~NestingAwareController().
std::vector<Stat> benchmark::nestingAware::NestingAwareController::instrumentations [private] |
Vector of benchmark statistics.
Definition at line 662 of file Benchmarking.h.
Referenced by count(), getInstrumentationID(), printCount(), printDuration(), 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().
boost::mutex benchmark::nestingAware::NestingAwareController::mutex [private] |
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().
std::map<std::string, ID> benchmark::nestingAware::NestingAwareController::name2id [private] |
Map from benchmark names to IDs.
Definition at line 664 of file Benchmarking.h.
Referenced by count(), duration(), and getInstrumentationID().
std::ostream* benchmark::nestingAware::NestingAwareController::output [private] |
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().
unsigned benchmark::nestingAware::NestingAwareController::sus [private] |
Level of suspending benchmarking (0 = not suspended).
Definition at line 676 of file Benchmarking.h.