blob: 5bc302ffbfc1a6a8109f1c6a95e921f5b0d6140c (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include "timer.hpp"
#include "compat/assert.hpp"
#include "compat/debug.hpp"
#include <cr/Debug.h>
#include <mg/Functions.h>
namespace floormat {
namespace {
#if 0
constexpr auto MAX = (uint64_t)-1, HALF = MAX/2;
static_assert(MAX - (MAX-0) <= 0);
static_assert(MAX - (MAX-1) <= 1);
static_assert(MAX - (MAX-2) <= 2);
static_assert(HALF + HALF + 1 == MAX);;
static_assert(MAX - HALF <= HALF+1);
//static_assert(MAX - (MAX-1) <= 0); // must fail
//static_assert(MAX - (MAX-2) <= 1); // must fail
//static_assert(MAX - HALF <= HALF); // must fail
#endif
} // namespace
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
|