lib: make drmtest_progress more robust

This commit is contained in:
Daniel Vetter 2012-10-09 17:50:40 +02:00
parent e5722bac9c
commit b8e384a4d5

View File

@ -542,13 +542,18 @@ void drmtest_permute_array(void *array, unsigned size,
void drmtest_progress(const char *header, uint64_t i, uint64_t total)
{
int div = 200;
if (i+1 >= total) {
fprintf(stderr, "\r%s100%%\n", header);
return;
}
if (total / 200 == 0)
div = 1;
/* only bother updating about every 0.5% */
if (i % (total / 200) == 0 || i+1 >= total) {
if (i % (total / div) == 0 || i+1 >= total) {
fprintf(stderr, "\r%s%3llu%%", header,
(long long unsigned) i * 100 / total);
}