Nektar++
|
Metric that finds the execution time in an output and tests it against an accepted value and tolerance. More...
#include <MetricExecutionTime.h>
Public Member Functions | |
~MetricExecutionTime () override | |
Public Member Functions inherited from Nektar::Metric | |
Metric (TiXmlElement *metric, bool generate) | |
Constructor. More... | |
virtual | ~Metric ()=default |
bool | Test (std::istream &pStdout, std::istream &pStderr) |
Calls a metric's v_Test function (or v_Generate if m_generate ). More... | |
void | Generate (std::istream &pStdout, std::istream &pStderr) |
std::string | GetType () |
Return metric type. More... | |
int | GetID () |
Return metric ID. More... | |
bool | SupportsAverage () const |
Return whether this metric supports averaging results from multiple runs. More... | |
Static Public Member Functions | |
static MetricSharedPtr | create (TiXmlElement *metric, bool generate) |
Static Public Attributes | |
static std::string | type |
Protected Member Functions | |
MetricExecutionTime (TiXmlElement *metric, bool generate) | |
Construct a new MetricExecutionTime object. More... | |
bool | v_Test (std::istream &pStdout, std::istream &pStderr) override |
Test output against a regular expression and its expected value. More... | |
void | v_Generate (std::istream &pStdout, std::istream &pStderr) override |
Generate an accepted execution time value using a test output or error stream. More... | |
virtual bool | v_Test (std::istream &pStdout, std::istream &pStderr)=0 |
Virtual function to test the metric. Should be redefined in derived classes. More... | |
virtual void | v_Generate (std::istream &pStdout, std::istream &pSrderr)=0 |
Virtual function to generate the metric. Should be redefined in derived classes. More... | |
Protected Attributes | |
std::regex | m_regex |
Regex used to match an execution time in a test output. More... | |
MetricExecutionTimeFieldValue | m_match |
Stores each execution time found in the test output. More... | |
bool | m_useStderr = false |
If true, use stderr for testing/generation instead of stdout. More... | |
Protected Attributes inherited from Nektar::Metric | |
int | m_id |
Stores the ID of this metric. More... | |
std::string | m_type |
Stores the type of this metric (uppercase). More... | |
bool | m_generate |
Determines whether to generate this metric or not. More... | |
bool | m_average = false |
Indicates whether a metric supports averaging results from multiple runs. More... | |
TiXmlElement * | m_metric |
Pointer to XML structure containing metric definition. More... | |
Metric that finds the execution time in an output and tests it against an accepted value and tolerance.
Definition at line 71 of file MetricExecutionTime.h.
|
inlineoverride |
Definition at line 74 of file MetricExecutionTime.h.
|
protected |
Construct a new MetricExecutionTime object.
If the metric is not a derived class, then this constructor will parse the regular expression from the metric's element in the test file, or use a default value if this doesn't exist. It will also see if an expected execution time and tolerance have been provided for the current computer's hostname. If this is the case, these will be used by v_Test
. If not, then a skip flag m_skip
will be set to true
and the test will automatically pass.
metric | |
generate |
Definition at line 65 of file MetricExecutionTime.cpp.
References ASSERTL0, Nektar::EmptyString(), Nektar::Metric::m_average, Nektar::Metric::m_generate, m_match, m_regex, Nektar::MetricExecutionTimeFieldValue::m_skip, Nektar::MetricExecutionTimeFieldValue::m_tolerance, Nektar::Metric::m_type, and Nektar::MetricExecutionTimeFieldValue::m_value.
Referenced by create().
|
inlinestatic |
Definition at line 78 of file MetricExecutionTime.h.
References MetricExecutionTime().
|
overrideprotectedvirtual |
Generate an accepted execution time value using a test output or error stream.
This function generate an execution time match by finding the first execution time in the output that matches m_regex
(provided in the test file).
pStdout | Reference to test output stream. |
pStderr | Reference to test error stream. |
Implements Nektar::Metric.
Definition at line 266 of file MetricExecutionTime.cpp.
References ASSERTL0, m_match, Nektar::Metric::m_metric, m_regex, Nektar::MetricExecutionTimeFieldValue::m_tolerance, Nektar::Metric::m_type, m_useStderr, and Nektar::MetricExecutionTimeFieldValue::m_value.
|
overrideprotectedvirtual |
Test output against a regular expression and its expected value.
This function will find the execution time for each test run in the output, using m_regex (provided in the test file). It will then average these times and compare them to the expected execution time for the current computer's hostname (this behaviour is defined in the constructor). If the average execution time falls outside of the tolerance then the test will fail.
If no execution time value is provided for the current computer's hostname, m_skip will be set to true and the test will automatically pass.
pStdout | Reference to test output stream. |
pStderr | Reference to test error stream. |
Implements Nektar::Metric.
Definition at line 154 of file MetricExecutionTime.cpp.
References ASSERTL0, m_match, m_regex, Nektar::MetricExecutionTimeFieldValue::m_skip, Nektar::MetricExecutionTimeFieldValue::m_tolerance, m_useStderr, and Nektar::MetricExecutionTimeFieldValue::m_value.
|
protected |
Stores each execution time found in the test output.
Definition at line 89 of file MetricExecutionTime.h.
Referenced by MetricExecutionTime(), v_Generate(), and v_Test().
|
protected |
Regex used to match an execution time in a test output.
Definition at line 87 of file MetricExecutionTime.h.
Referenced by MetricExecutionTime(), v_Generate(), and v_Test().
|
protected |
If true, use stderr for testing/generation instead of stdout.
Definition at line 91 of file MetricExecutionTime.h.
Referenced by v_Generate(), and v_Test().
|
static |
Definition at line 83 of file MetricExecutionTime.h.