I've searched SO and found relevant questions answered but I'm confused about the three different clock definitions. Considering I compile with Mingw on Windows;
- I wonder whether the code below is OK or not? (I do not really need nanoseconds or microseconds precision; just testing...)
- Which one should I use?
- std::chrono::high_resolution_clock
- std::chrono::system_clock
- std::chrono::steady_clock
#include <iostream>
#include <chrono>
...
...
...
void printTimeElapsed(
    std::chrono::high_resolution_clock::time_point t0,
    std::chrono::high_resolution_clock::time_point t1)
{
    int64_t hh; // hour
    int64_t mm; // min
    int64_t ss; // sec
    int64_t ml; // millisec
    int64_t mc; // microsec
    int64_t ns; // nanosec
    ns = std::chrono::duration_cast<std::chrono::nanoseconds>(t1 - t0).count();
    std::cout << ns << std::endl;
    mc = ns / 1000;
    ns %= 1000;
    ml = mc / 1000;
    mc %= 1000;
    ss = ml / 1000;
    ml %= 1000;
    mm = ss / 60;
    ss %= 60;
    hh = mm / 60;
    mm %= 60;
    std::cout
        << std::setfill('0') << std::setw(3) << hh << ":"
        << std::setfill('0') << std::setw(2) << mm << ":"
        << std::setfill('0') << std::setw(2) << ss << "."
        << std::setfill('0') << std::setw(3) << ml << "."
        << std::setfill('0') << std::setw(3) << mc << "."
        << std::setfill('0') << std::setw(3) << ns << std::endl;
    return;
}
...
...
...
int main(
    int argc,
    char *argv[])
{
    std::chrono::high_resolution_clock::time_point t0;
    std::chrono::high_resolution_clock::time_point t1;
    ...
    ...
    t0 = std::chrono::high_resolution_clock::now();
    /* call the function to be measured */
    t1 = std::chrono::high_resolution_clock::now();
    printTimeElapsed(t0, t1);
    ...
    ...
    return (0);       
}
 
    