static qint64 elapsedAndRestart(qint64 sec, qint64 frac,
                                qint64 *nowsec, qint64 *nowfrac)
{
    do_gettime(nowsec, nowfrac);
    sec = *nowsec - sec;
    frac = *nowfrac - frac;
    return sec * Q_INT64_C(1000) + frac / fractionAdjustment();
}
qint64 QElapsedTimer::restart()
{
    QPair<long, long> r = do_gettime();
    qint64 oldt1 = t1;
    qint64 oldt2 = t2;
    t1 = r.first;
    t2 = r.second;

    r.first -= oldt1;
    r.second -= oldt2;
    return r.first * Q_INT64_C(1000) + r.second / fractionAdjustment();
}
qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const
{
    qint64 secs = other.t1 - t1;
    qint64 fraction = other.t2 - t2;
    return secs * Q_INT64_C(1000) + fraction / fractionAdjustment();
}
qint64 QElapsedTimer::msecsSinceReference() const
{
    return t1 * Q_INT64_C(1000) + t2 / fractionAdjustment();
}