dlvhex
2.5.0
|
Supports benchmarking of different components of dlvhex. More...
#include <include/dlvhex2/Benchmarking.h>
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 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 BenchmarkController & | Instance () |
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< Stat > | instrumentations |
Vector of benchmark statistics. | |
std::map< std::string, ID > | name2id |
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). |
Supports benchmarking of different components of dlvhex.
Definition at line 181 of file Benchmarking.h.
Destructor.
Output benchmark results, destruct.
Definition at line 66 of file Benchmarking.cpp.
References benchmark::simple::BenchmarkController::Stat::count, benchmark::simple::BenchmarkController::Stat::duration, instrumentations, myID, printInformation(), benchmark::simple::BenchmarkController::Stat::running, and benchmark::simple::BenchmarkController::Stat::start.
Constructor.
Init, display start of benchmarking.
Definition at line 59 of file Benchmarking.cpp.
References getInstrumentationID(), myID, and start().
Referenced by Instance().
std::string benchmark::simple::BenchmarkController::count | ( | const std::string & | identifier, |
int | width = 0 |
||
) | const |
Outputs a count value.
identifier | Benchmark value to output. |
width | See 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.
id | ID of the benchmark to count. |
increment | Increment 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.
identifier | Benchmark value to output. |
width | See BenchmarkController::printInSecs. |
Definition at line 156 of file Benchmarking.cpp.
References getStat(), name2id, printInSecs(), and sus.
void benchmark::simple::BenchmarkController::finish | ( | ) | [static] |
Delete the singleton instance.
Causes destructor to be called.
Definition at line 88 of file Benchmarking.cpp.
ID benchmark::simple::BenchmarkController::getInstrumentationID | ( | const std::string & | name | ) |
Get ID or register new one.
name | Identifier. |
name
. Definition at line 111 of file Benchmarking.cpp.
References instrumentations, maxID, mutex, and name2id.
Referenced by BenchmarkController(), resume(), snapshot(), and suspend().
const Stat& benchmark::simple::BenchmarkController::getStat | ( | ID | id | ) | const [inline] |
Retrieve Stat of id
.
id
. Definition at line 283 of file Benchmarking.h.
Referenced by count(), and duration().
Singleton access.
Definition at line 94 of file Benchmarking.cpp.
References BenchmarkController().
Stop and do not record anything.
If not running, do not do anything.
id | ID 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.
out | Output stream. |
id | ID whose information is to be printed. |
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.
out | Output stream. |
id | ID whose duration is to be printed. |
Definition at line 408 of file Benchmarking.h.
References benchmark::simple::BenchmarkController::Stat::duration, instrumentations, mutex, and printInSecs().
void benchmark::simple::BenchmarkController::printInformation | ( | const Stat & | st | ) | [inline] |
Print information about stat.
st | Identifies a benchmark value. |
Definition at line 382 of file Benchmarking.h.
References benchmark::simple::BenchmarkController::Stat::count, benchmark::simple::BenchmarkController::Stat::duration, benchmark::simple::BenchmarkController::Stat::name, output, and printInSecs().
Referenced by ~BenchmarkController().
void benchmark::simple::BenchmarkController::printInformationContinous | ( | Stat & | st, |
const Duration & | dur | ||
) | [inline] |
Print continuous information about stat.
st | Identifies a benchmark value. |
Definition at line 416 of file Benchmarking.h.
References benchmark::simple::BenchmarkController::Stat::count, benchmark::simple::BenchmarkController::Stat::duration, benchmark::simple::BenchmarkController::Stat::name, output, printInSecs(), benchmark::simple::BenchmarkController::Stat::prints, printSkip, and benchmark::simple::BenchmarkController::Stat::running.
std::ostream & benchmark::simple::BenchmarkController::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 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.
void benchmark::simple::BenchmarkController::setOutput | ( | std::ostream * | o | ) |
Sets the output stream for printing.
o | Output stream to use in the following. |
Definition at line 101 of file Benchmarking.cpp.
References output.
Amount of accumulated output (default: each call).
skip | Interval. |
Definition at line 106 of file Benchmarking.cpp.
References printSkip.
void benchmark::simple::BenchmarkController::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 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.
fromstr | Benchmark to copy. |
tostr | Benchmark to copy fromstr into. |
Definition at line 199 of file Benchmarking.cpp.
References getInstrumentationID(), snapshot(), and sus.
void benchmark::simple::BenchmarkController::start | ( | ID | id | ) | [inline] |
Start a benchmark.
id | ID of the benchmark to start. |
Definition at line 436 of file Benchmarking.h.
References instrumentations, benchmark::simple::BenchmarkController::Stat::level, mutex, benchmark::simple::BenchmarkController::Stat::running, benchmark::simple::BenchmarkController::Stat::start, and sus.
Referenced by BenchmarkController(), and suspend().
void benchmark::simple::BenchmarkController::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 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.
std::vector<Stat> benchmark::simple::BenchmarkController::instrumentations [private] |
Vector of benchmark statistics.
Definition at line 345 of file Benchmarking.h.
Referenced by count(), getInstrumentationID(), invalidate(), printCount(), printDuration(), snapshot(), start(), stop(), and ~BenchmarkController().
ID to be used for the next benchmark registered.
Definition at line 343 of file Benchmarking.h.
Referenced by getInstrumentationID().
boost::mutex benchmark::simple::BenchmarkController::mutex [private] |
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().
std::ostream* benchmark::simple::BenchmarkController::output [private] |
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().
unsigned benchmark::simple::BenchmarkController::sus [private] |
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().