Fixed possible division by zero in qrtest.

This commit is contained in:
Daniel Beer 2012-11-13 10:43:36 +13:00
parent a3142bc6b4
commit b7a6827b54

View file

@ -49,16 +49,19 @@ static void print_result(const char *name, struct result_info *info)
{ {
puts("----------------------------------------" puts("----------------------------------------"
"---------------------------------------"); "---------------------------------------");
printf("%s: %d files, %d codes, %d decoded (%d failures), " printf("%s: %d files, %d codes, %d decoded (%d failures)",
"%d%% success rate\n",
name, info->file_count, info->id_count, info->decode_count, name, info->file_count, info->id_count, info->decode_count,
(info->id_count - info->decode_count), (info->id_count - info->decode_count));
if (info->id_count)
printf(", %d%% success rate",
(info->decode_count * 100 + info->id_count / 2) / (info->decode_count * 100 + info->id_count / 2) /
info->id_count); info->id_count);
printf("\n");
printf("Total time [load: %ld, identify: %ld, total: %ld]\n", printf("Total time [load: %ld, identify: %ld, total: %ld]\n",
CLOCK_TO_MS(info->load_time), CLOCK_TO_MS(info->load_time),
CLOCK_TO_MS(info->identify_time), CLOCK_TO_MS(info->identify_time),
CLOCK_TO_MS(info->total_time)); CLOCK_TO_MS(info->total_time));
if (info->file_count)
printf("Average time [load: %ld, identify: %ld, total: %ld]\n", printf("Average time [load: %ld, identify: %ld, total: %ld]\n",
CLOCK_TO_MS(info->load_time / info->file_count), CLOCK_TO_MS(info->load_time / info->file_count),
CLOCK_TO_MS(info->identify_time / info->file_count), CLOCK_TO_MS(info->identify_time / info->file_count),