HDK
|
Wrapper around the nanobench object for unit performance tests. More...
#include <UT_TestManager.h>
Public Member Functions | |
UT_TestBench (const UT_StringRef &title) | |
~UT_TestBench () | |
bool | run (const UT_StringRef &test_name, UT_Function< void(UT_TestUnit &)> fn) |
bool | saveAndCompareResults (const UT_StringRef &file_name_root) const |
Wrapper around the nanobench object for unit performance tests.
This class wraps the nanobench::Bench object for performance testing, and streamlines the workflows for deploying it in unit tests.
Example:
Definition at line 200 of file UT_TestManager.h.
UT_TestBench::UT_TestBench | ( | const UT_StringRef & | title | ) |
UT_TestBench::~UT_TestBench | ( | ) |
bool UT_TestBench::run | ( | const UT_StringRef & | test_name, |
UT_Function< void(UT_TestUnit &)> | fn | ||
) |
Runs and times the given function f
. Prints the unit test wall clock time to the output as a summary.
Stores the nanobench timing in the internal structures for later comparisons and detection of the performance regressions.
It passes a UT_TestUnit to that function, for setting status. I.e., bad results may be fast, but they should not be considered for parformance timing, and hence status should be set to error. Returns true if that status is a success or false otherwise.
test_name | The name of the timing test to appear in the reports. |
fn | The test function to time. |
bool UT_TestBench::saveAndCompareResults | ( | const UT_StringRef & | file_name_root | ) | const |
Saves the nanobench timings from the previously performed runs to a file with the given name in the current working directory. Compares the timings with a similarly named file in a ./correct subdir, if it exists. If it does not exists, it creates one as a base line for the future runs. comparing to the baseline times, and false otherise. Prints the report of the current run times comparison to the times recorded as a baseline in the ./correct file. Returns true if the current timings are within an acceptable delta
file_name_root | The base name to use for constructing the timing result file name. |