Files
dusklight/libs/revolution/src/os/OSStopwatch.c
T
Luke Street 4df8ccc871 Reorganize library code into libs/ (#3119)
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN}

* Update configure.py and project.py for new libs structure

* Refactor `#include <dolphin/x.h>` -> `<x.h>`

* Remove `__REVOLUTION_SDK__` forwards from dolphin

* Fix dolphin/ references in revolution

* Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__`

* Always build TRK against dolphin headers

* Resolve revolution SDK header resolution issues
2026-03-01 14:35:36 -08:00

56 lines
1.4 KiB
C

#include <revolution.h>
#include <revolution/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));
}