2021-11-30 21:29:18 -06:00
|
|
|
#include "debug.h"
|
|
|
|
|
2023-09-02 06:53:52 -05:00
|
|
|
#include "stb_ds.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "sokol/sokol_time.h"
|
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
unsigned long long triCount = 0;
|
|
|
|
|
2023-09-02 06:53:52 -05:00
|
|
|
void prof_start(struct d_prof *prof)
|
|
|
|
{
|
2023-12-21 17:21:01 -06:00
|
|
|
arrsetlen(prof->ms, prof->laps);
|
|
|
|
}
|
|
|
|
|
|
|
|
void prof_reset(struct d_prof *prof)
|
|
|
|
{
|
2023-09-02 06:53:52 -05:00
|
|
|
prof->lap = stm_now();
|
|
|
|
}
|
|
|
|
|
2023-12-21 17:21:01 -06:00
|
|
|
float prof_lap_avg(struct d_prof *prof)
|
|
|
|
{
|
|
|
|
float avg;
|
|
|
|
for (int i = 0; i < arrlen(prof->ms); i++)
|
|
|
|
avg += prof->ms[i];
|
|
|
|
|
|
|
|
avg /= arrlen(prof->ms);
|
|
|
|
return avg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void prof_lap(struct d_prof *prof)
|
2023-09-02 06:53:52 -05:00
|
|
|
{
|
2023-12-21 17:21:01 -06:00
|
|
|
if (prof->ms == NULL)
|
|
|
|
prof_start(prof);
|
|
|
|
|
|
|
|
if (arrlen(prof->ms) >= prof->laps) {
|
|
|
|
YughWarn("Profiled time of %s is avg %g", prof->name, prof_lap_avg(prof));
|
|
|
|
arrsetlen(prof->ms, 0);
|
|
|
|
}
|
2023-09-02 06:53:52 -05:00
|
|
|
uint64_t t = stm_since(prof->lap);
|
|
|
|
arrput(prof->ms, stm_sec(t));
|
|
|
|
}
|
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
void resetTriangles()
|
|
|
|
{
|
2023-09-02 06:53:52 -05:00
|
|
|
triCount = 0;
|
2022-02-06 10:14:57 -06:00
|
|
|
}
|