When executed with all logging enabled (e.g. test --log_level=all
), a unit test created with the Boost Unit Test Framework will report how long an individual test case took with a message like this:
Leaving test case "testRecursiveSchedule"; testing time: 2196mks
The unit displayed there, mks, mystifies me. I understand that Meters-Kilograms-Seconds is a system for metric measurement, but Boost is clearly displaying a time measurement only. Shouldn't the unit in this case be ms if milliseconds or μs (or perhaps us) if microseconds? Is mks commonly understood as an abbreviation for microseconds?
Note that according to the Boost unit test framework source code, the unit displayed will be ms if the elapsed time happens to be evenly divisible by 1000, in which case it will be divided by 1000 before being displayed. That's consistent with the idea that mks is meant to imply microseconds.
But does it? Or is Boost being idiosyncratic here?
Here is my guess: mks means microseconds.
Gennadiy Rozental, the author of Boost.Test, is Russian-speaking, and in Russian microsecond is "микросекунда", abbreviated as "мкс", which can be transliterated as "mks". Sometimes I see "mks" accidentally appearing in works of Russian-speaking people.
The mechanism used to time the tests is
boost::timer tc_timer;
test_unit_id bkup = m_curr_test_case;
m_curr_test_case = tc.p_id;
unit_test_monitor_t::error_level run_result = unit_test_monitor.execute_and_translate( tc );
unsigned long elapsed = static_cast<unsigned long>( tc_timer.elapsed() * 1e6 );
Boost Timer is documented here and promises the following:
double elapsed() const // return elapsed time in seconds
{ return double(std::clock() - _start_time) / CLOCKS_PER_SEC; }
As you can see Boost Tests passes microseconds to the observer's test_unit_finish
implementations:
BOOST_TEST_FOREACH( test_observer*, to, m_observers )
to->test_unit_finish( tc, elapsed );
And they indeed print it typically as:
if( elapsed % 1000 == 0 )
output << elapsed/1000 << "ms";
else
output << elapsed << "mks";
or raw microseconds for XML:
if( tu.p_type == tut_case )
ostr << "<TestingTime>" << elapsed << "</TestingTime>";
The effective accuracy depends on the system:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With