Add number of passes to benchmark output

This commit is contained in:
2022-11-23 15:46:21 +00:00
parent 07c1fc7a0f
commit d74b5410b6
3 changed files with 20 additions and 12 deletions

13
main.c
View File

@@ -65,7 +65,7 @@ int main(void)
putchar('\b');
puts("100%");
bool res[NPUZZLES];
int res[NPUZZLES];
struct timespec start, end;
fputs("Solving... ", stdout);
fflush(stdout);
@@ -85,14 +85,21 @@ int main(void)
const double avg_micros = tot_micros / NPUZZLES;
unsigned solved = 0;
unsigned tot_passes = 0;
for (i = 0; i < NPUZZLES; ++i) {
if (res[i] && check(&puzzles[i]) == SOLVED)
if (res[i] < 0)
continue;
if (check(&puzzles[i]) == SOLVED)
++solved;
tot_passes += (unsigned long)res[i];
}
const double succ_rate = (double)solved / NPUZZLES;
const unsigned avg_passes = tot_passes / NPUZZLES;
puts("\n SUMMARY\n =======");
printf("Success rate: %.0lf%%\n", 1e2 * (double)solved / NPUZZLES);
printf("Success rate: %.0lf%%\n", 1e2 * succ_rate);
printf("Average time: %.3lf µs\n", avg_micros);
printf("Average n.o. passes: %u\n", avg_passes);
return 0;
}