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,20 +49,23 @@ 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));
(info->decode_count * 100 + info->id_count / 2) / if (info->id_count)
info->id_count); printf(", %d%% success rate",
(info->decode_count * 100 + info->id_count / 2) /
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));
printf("Average time [load: %ld, identify: %ld, total: %ld]\n", if (info->file_count)
CLOCK_TO_MS(info->load_time / info->file_count), printf("Average time [load: %ld, identify: %ld, total: %ld]\n",
CLOCK_TO_MS(info->identify_time / info->file_count), CLOCK_TO_MS(info->load_time / info->file_count),
CLOCK_TO_MS(info->total_time / info->file_count)); CLOCK_TO_MS(info->identify_time / info->file_count),
CLOCK_TO_MS(info->total_time / info->file_count));
} }
static void add_result(struct result_info *sum, struct result_info *inf) static void add_result(struct result_info *sum, struct result_info *inf)