Merge pull request #353 from guzba/master

fix benchmarks
This commit is contained in:
treeform 2021-12-23 21:54:06 -08:00 committed by GitHub
commit 95c61ac068
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -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)

View file

@ -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"