Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the "mks" unit reported by the Boost Unit Test Framework?

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?

like image 772
OldPeculier Avatar asked Mar 10 '15 17:03

OldPeculier


2 Answers

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.

like image 199
Ilya Popov Avatar answered Sep 19 '22 22:09

Ilya Popov


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:

enter image description here

like image 40
sehe Avatar answered Sep 21 '22 22:09

sehe