Add more benchmarks, add subcount option

This commit is contained in:
2025-10-13 11:17:11 +03:00
parent 35b2e71753
commit 3f7b872f0f
20 changed files with 1479 additions and 22 deletions

View File

@@ -14,6 +14,7 @@ struct BH_Bench
BH_BenchCallback cb;
int started;
size_t iterations;
size_t subcount;
};
@@ -51,6 +52,7 @@ void BH_BenchAdd(const char *name,
bench->cb = cb;
bench->started = 0;
bench->iterations = 0;
bench->subcount = 1;
/* Append benchmark entry */
current = root;
@@ -84,8 +86,8 @@ int BH_BenchIter(BH_Bench *state)
if (millis > 1000 || state->iterations > 1000000000)
{
float ips, ns;
ips = state->iterations / (millis / 1000.0f);
ns = (millis * 1000000.0) / state->iterations;
ips = state->iterations / (millis / 1000.0f) * state->subcount;
ns = (millis * 1000000.0) / state->iterations / state->subcount;
printf("%-12s %.2f ips (%.2f ns)\n", state->name, ips, ns);
return 0;
}
@@ -93,6 +95,13 @@ int BH_BenchIter(BH_Bench *state)
}
void BH_BenchSubcount(BH_Bench *state,
size_t count)
{
state->subcount = count;
}
int BH_BenchRun(void)
{
BH_Bench *current;