summaryrefslogtreecommitdiffhomepage
path: root/src/timer-ns.cpp
blob: b467ce19b6ae13d61ae54d362c4bda1ada2f783d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "timer.hpp"
#include "compat/assert.hpp"
#include "compat/debug.hpp"
#include <cr/Debug.h>
#include <mg/Functions.h>

namespace floormat {



Debug& operator<<(Debug& dbg, const Ns& box)
{
    const auto value = (float)((double)box.stamp * 1e-6);
    const auto absval = Math::abs(value);
    int precision;
    if (absval < 2)
        precision = 4;
    else if (absval < 5)
        precision = 2;
    else if (absval < 100)
        precision = 1;
    else
        precision = 0;
    auto flags = dbg.flags();
    dbg << "";
    dbg.setFlags(flags | Debug::Flag::NoSpace);
    //dbg << "{";
    dbg << fraction(value, precision);
    dbg << " ms";
    //dbg << "}";
    dbg.setFlags(flags);
    return dbg;
}

} // namespace floormat