blob: a5e4e3a5aa6a2140a178f0a1320fb46bc394ebb1 (
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
54
55
|
#include <dolphin/dolphin.h>
#include <dolphin/os.h>
void OSInitStopwatch(OSStopwatch* sw, char* name) {
sw->name = name;
sw->total = 0;
sw->hits = 0;
sw->min = 0x00000000FFFFFFFF;
sw->max = 0;
}
void OSStartStopwatch(OSStopwatch* sw) {
sw->running = TRUE;
sw->last = OSGetTime();
}
void OSStopStopwatch(OSStopwatch* sw) {
OSTime interval;
if (sw->running) {
interval = OSGetTime() - sw->last;
sw->total += interval;
sw->running = FALSE;
sw->hits++;
if (sw->max < interval) {
sw->max = interval;
}
if (interval < sw->min) {
sw->min = interval;
}
}
}
OSTime OSCheckStopwatch(OSStopwatch* sw) {
OSTime currTotal;
currTotal = sw->total;
if (sw->running) {
currTotal += OSGetTime() - sw->last;
}
return currTotal;
}
void OSResetStopwatch(OSStopwatch* sw) {
OSInitStopwatch(sw, sw->name);
}
void OSDumpStopwatch(OSStopwatch* sw) {
OSReport("Stopwatch [%s] :\n", sw->name);
OSReport("\tTotal= %lld us\n", OSTicksToMicroseconds(sw->total));
OSReport("\tHits = %d \n", sw->hits);
OSReport("\tMin = %lld us\n", OSTicksToMicroseconds(sw->min));
OSReport("\tMax = %lld us\n", OSTicksToMicroseconds(sw->max));
OSReport("\tMean = %lld us\n", OSTicksToMicroseconds(sw->total/sw->hits));
}
|