benchmarks: eina: make sure we do not divide by zero

Make sure we do not divide by i if it is zero here.

CID: 1400768

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D11956
This commit is contained in:
Stefan Schmidt 2020-06-09 14:22:19 +02:00
parent 794c52d200
commit 9c773ed5cf
1 changed files with 6 additions and 3 deletions

View File

@ -429,9 +429,12 @@ ecore_hash_dump_stats(Ecore_Hash *hash)
sum_n += (double)n;
}
}
variance = (sum_n_2 - ((sum_n * sum_n) / (double)i)) / (double)i;
printf("Average length: %f\n\tvariance^2: %f", (sum_n / (double)i),
variance);
if (i)
{
variance = (sum_n_2 - ((sum_n * sum_n) / (double)i)) / (double)i;
printf("Average length: %f\n\tvariance^2: %f", (sum_n / (double)i),
variance);
}
}
static int