MNE-CPP
0.1.9
A Framework for Electrophysiology
|
#include <mnetracer.h>
Public Member Functions | |
MNETracer (const std::string &file, const std::string &function, int lineNumber) | |
MNETracer constructor will check if the class "is enabled". If it is, it will record the creation time with respect to the ZeroTime set during the last enable function call. It will also write that time to the output file and if needed, it will also print it to terminal. More... | |
~MNETracer () | |
bool | printToTerminalIsSet () |
void | setPrintToTerminal (bool s) |
Static Public Member Functions | |
static void | enable (const std::string &jsonFileName) |
static void | enable () |
static void | disable () |
disable If the class "is enabled" (it's static variabable ms_bIsEnabled is true), the output file has a Footer written to it and the output file stream is closed. Finally, the static member variable ms_bIsEnabled is set to false. | |
static void | start (const std::string &jsonFileName) |
Convenience overload of the method enable. More... | |
static void | start () |
Convenience overload of the method enable. | |
static void | stop () |
Convenience overload of the method disable. | |
static void | traceQuantity (const std::string &name, long val) |
traceQuantity Allows to keep track of a specific variable in the output tracing file. More... | |
The MNETracer is defined as a single class helper tool to measure execution times of blocks of code (includeing scope blocks of code between brackets) that formats the output so that it is compatible with Chrome browser's Tracing application (json format).
The class is defined so that it has a some settings (ie. output file, zero time, etc...) which correspond to static variables shared and accessible from all the instances of this class MNETracer. Each instance, in its contructor will record the creation time and write to file that begin-measurement event. Whenever the MNETracer object is destructued (normally by falling out of scope), the destructor of this class MNETracer will be called and it is in the desctructor where the end-measurement event is recorded and written to file. So the time-alive (time between the constructor and the desctructor calls, for objects of this class, will be linked to a specific scope (i.e. function).
Since this class is oriented as a development tool, all the events are written to the output file stream directly, so there should be not much difficulty recovering the results even if the application crashed.
There are some additional macros defined to make is handy for the user to use this class. MNE_TRACER_ENABLE(filename) and MNE_TRACER_DISABLE macros will set the static variables like the output file initialization and a few other needed variables. This should be called before any MNETracer is created, and after the last MNETracer object is destructed. For instance, in the main.cpp file. The MNE_TRACE() macro is to be used for marking which method, function or block of code is to be measured and traced.
Definition at line 120 of file mnetracer.h.
MNETracer::MNETracer | ( | const std::string & | file, |
const std::string & | function, | ||
int | lineNumber | ||
) |
MNETracer constructor will check if the class "is enabled". If it is, it will record the creation time with respect to the ZeroTime set during the last enable function call. It will also write that time to the output file and if needed, it will also print it to terminal.
function | Function name where the MNETracer object is created. |
file | File name where the MNETracer object is created. |
num | Line number where the MNETracer object is created. |
Definition at line 54 of file mnetracer.cpp.
MNETracer::~MNETracer | ( | ) |
MNETracer destructor will check if the class "is enabled". If it is, it will record the destruction time with respect to the ZeroTime set during the last enable function call. It will also write that time to the output file and, if needed, it will also print it to terminal.
Definition at line 74 of file mnetracer.cpp.
|
static |
Overriden function for enable, but using the default filename.
Definition at line 103 of file mnetracer.cpp.
|
static |
The enable function initializes an output file (output file stream ie std::ofstream) to write the events.
jsonFileName | is the name of the output file to configure as the outuput file (it is in json format). |
Definition at line 90 of file mnetracer.cpp.
bool MNETracer::printToTerminalIsSet | ( | ) |
Getter function for the member variable that defines whether the output should be printed to terminal, or only to a file.
Definition at line 297 of file mnetracer.cpp.
void MNETracer::setPrintToTerminal | ( | bool | s | ) |
Setter function for the member variable that defines whether the output should be printed to terminal, or only to a file.
s | bool value to set the output to terminal control member variable. |
Definition at line 304 of file mnetracer.cpp.
|
static |
Convenience overload of the method enable.
jsonFileName |
Definition at line 123 of file mnetracer.cpp.
|
static |
traceQuantity Allows to keep track of a specific variable in the output tracing file.
name | Name of the variable to keep track of. |
val | Value of the variable to keep track of. |
Definition at line 144 of file mnetracer.cpp.