From e4542de6f2affd878060267057eee26a663f7404 Mon Sep 17 00:00:00 2001 From: Mike Dussault Date: Mon, 11 Oct 2021 14:21:08 -0700 Subject: [PATCH] Fixed random image generation, and now it shows a proper (giant) perf difference between images that take longer for Zone's FILTERED_PIXELS detection to deal with. --- src/zmbenchmark.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/zmbenchmark.cpp b/src/zmbenchmark.cpp index 90a2316b3..d194fc0a8 100644 --- a/src/zmbenchmark.cpp +++ b/src/zmbenchmark.cpp @@ -55,12 +55,16 @@ std::shared_ptr GenerateRandomImage( ZM_COLOUR_GRAY8, ZM_SUBPIX_ORDER_NONE); - const int range = maxVal - minVal + 1; + const int randMax = RAND_MAX; + const int range = maxVal - minVal; + for (int y=0; y < height; y++) { uint8_t *row = (uint8_t*)image->Buffer(0, y); - for (int x=0; x < width; x++) - row[x] = (rand() * range) / RAND_MAX + minVal; + for (int x=0; x < width; x++) { + uint64_t randVal = rand(); + row[x] = (uint8_t)((randVal * range) / randMax + minVal); + } } return std::shared_ptr(image);