|
23 | 23 | #define deadline_us 2500
|
24 | 24 | #define GOOD_SYNC_MIN 0.6
|
25 | 25 |
|
26 |
| -typedef std::chrono::time_point<std::chrono::high_resolution_clock> Tick; |
| 26 | +typedef std::chrono::time_point<std::chrono::high_resolution_clock> Ticks; |
27 | 27 |
|
28 |
| -static inline Tick tickNow() |
| 28 | +static inline Ticks tickNow() |
29 | 29 | {
|
30 | 30 | return std::chrono::high_resolution_clock::now();
|
31 | 31 | }
|
32 | 32 |
|
33 |
| -static inline uint64_t tickNano(Tick& sta, Tick& end) |
| 33 | +static inline uint64_t tickNano(Ticks& sta, Ticks& end) |
34 | 34 | {
|
35 | 35 | return uint64_t(std::chrono::duration_cast<std::chrono::nanoseconds>(end - sta).count());
|
36 | 36 | }
|
37 | 37 |
|
38 | 38 | struct Results {
|
39 |
| - uint64_t m_best = 0xffffffffffffffffULL; |
40 |
| - uint64_t m_worst = 0; |
41 |
| - uint64_t m_transactions = 0; |
42 |
| - uint64_t m_total_time = 0; |
| 39 | + uint64_t best = 0xffffffffffffffffULL; |
| 40 | + uint64_t worst = 0; |
| 41 | + uint64_t trans = 0; |
| 42 | + uint64_t total_time = 0; |
43 | 43 | uint64_t m_miss = 0;
|
44 | 44 | bool tracing;
|
45 | 45 | explicit Results(bool _tracing)
|
46 | 46 | : tracing(_tracing)
|
47 | 47 | {
|
48 | 48 | }
|
49 |
| - inline bool miss_deadline(uint64_t nano) |
| 49 | + inline bool miss_deadline(uint64_t nanos) |
50 | 50 | {
|
51 |
| - return nano > deadline_us * 1000; |
| 51 | + return nanos > deadline_us * 1000; |
52 | 52 | }
|
53 |
| - void add_time(uint64_t nano) |
| 53 | + void add_time(uint64_t nanos) |
54 | 54 | {
|
55 |
| - m_best = std::min(nano, m_best); |
56 |
| - m_worst = std::max(nano, m_worst); |
57 |
| - m_transactions += 1; |
58 |
| - m_total_time += nano; |
59 |
| - if (miss_deadline(nano)) |
| 55 | + best = std::min(nanos, best); |
| 56 | + worst = std::max(nanos, worst); |
| 57 | + trans += 1; |
| 58 | + total_time += nanos; |
| 59 | + if (miss_deadline(nanos)) |
60 | 60 | m_miss++;
|
61 | 61 | }
|
62 | 62 | void dump()
|
63 | 63 | {
|
64 |
| - double best = (double)m_best / 1.0E6; |
65 |
| - double worst = (double)m_worst / 1.0E6; |
66 |
| - double average = (double)m_total_time / m_transactions / 1.0E6; |
67 |
| - // TODO: libjson? |
| 64 | + double best = (double)best / 1.0E6; |
| 65 | + double worst = (double)worst / 1.0E6; |
| 66 | + double average = (double)total_time / trans / 1.0E6; |
68 | 67 | int W = DUMP_PRESICION + 2;
|
69 | 68 |
|
70 | 69 | printf("{ \"avg\":%*.*f,\"wst\":%*.*f,\"bst\":%*.*f,\"miss\":%" PRIu64 ",\"meetR\":%.3f}\n",
|
71 | 70 | W, DUMP_PRESICION, average, W, DUMP_PRESICION, worst, W, DUMP_PRESICION,
|
72 |
| - best, m_miss, 1.0 - (double)m_miss / m_transactions); |
| 71 | + best, m_miss, 1.0 - (double)m_miss / trans); |
73 | 72 | }
|
74 | 73 | };
|
75 | 74 |
|
|
0 commit comments