From 18592c446a3d08bfceb1e858fdc78c1d390ca2b1 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Thu, 23 Dec 2021 23:31:41 -0600 Subject: [PATCH] fix benchmarks --- tests/benchmark_images_blur.nim | 8 ++++---- tests/benchmark_images_loop.nim | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/benchmark_images_blur.nim b/tests/benchmark_images_blur.nim index b1a41c5..747ceba 100644 --- a/tests/benchmark_images_blur.nim +++ b/tests/benchmark_images_blur.nim @@ -42,10 +42,10 @@ proc blurSlower*( for xx in x - radius ..< min(x + radius, 0): values += outOfBounds * kernel[xx - x + radius] for xx in max(x - radius, 0) .. min(x + radius, image.width - 1): - values += image.getRgbaUnsafe(xx, y) * kernel[xx - x + radius] + values += image.unsafe[xx, y] * kernel[xx - x + radius] for xx in max(x - radius, image.width) .. x + radius: values += outOfBounds * kernel[xx - x + radius] - blurX.setRgbaUnsafe(x, y, rgbx(values)) + blurX.unsafe[x, y] = rgbx(values) # Blur in the Y direction. for y in 0 ..< image.height: @@ -54,10 +54,10 @@ proc blurSlower*( for yy in y - radius ..< min(y + radius, 0): values += outOfBounds * kernel[yy - y + radius] for yy in max(y - radius, 0) .. min(y + radius, image.height - 1): - values += blurX.getRgbaUnsafe(x, yy) * kernel[yy - y + radius] + values += blurX.unsafe[x, yy] * kernel[yy - y + radius] for yy in max(y - radius, image.height) .. y + radius: values += outOfBounds * kernel[yy - y + radius] - image.setRgbaUnsafe(x, y, rgbx(values)) + image.unsafe[x, y] = rgbx(values) let image = newImage(1920, 1080) diff --git a/tests/benchmark_images_loop.nim b/tests/benchmark_images_loop.nim index e2728b4..34b66ee 100644 --- a/tests/benchmark_images_loop.nim +++ b/tests/benchmark_images_loop.nim @@ -7,7 +7,7 @@ timeIt "x then y": var sum: uint64 for x in 0 ..< image.width: for y in 0 ..< image.height: - let pixel = image.getRgbaUnsafe(x, y) + let pixel = image.unsafe[x, y] sum += pixel.r + pixel.g + pixel.b + pixel.a if sum == 0: echo "0" @@ -17,7 +17,7 @@ timeIt "y then x": var sum: uint64 for y in 0 ..< image.height: for x in 0 ..< image.width: - let pixel = image.getRgbaUnsafe(x, y) + let pixel = image.unsafe[x, y] sum += pixel.r + pixel.g + pixel.b + pixel.a if sum == 0: echo "0"