From 690250faddbd414d2a4c428be6958ef232cd7bd3 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Fri, 3 Jun 2022 00:25:53 -0500 Subject: [PATCH] update --- tests/benchmark_png.nim | 73 ++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/tests/benchmark_png.nim b/tests/benchmark_png.nim index 29ad32a..81fcf76 100644 --- a/tests/benchmark_png.nim +++ b/tests/benchmark_png.nim @@ -5,38 +5,42 @@ let filePath = "tests/fileformats/png/lenna.png" data = readFile(filePath) -timeIt "pixie decode": - keep decodePngRaw(data) +block: + let + decodedPng = decodePng(data) + decodedImage = newImage(decodedPng) -timeIt "pixie encode": - let decoded = decodePngRaw(data) - keep encodePng(decoded).len + timeIt "pixie decode": + discard decodePng(data) -timeIt "pixie decode + alpha": - keep decodePng(data) + timeIt "pixie encode": + discard encodePng(decodedPng) -timeIt "pixie encode + alpha": - let decoded = decodePng(data) - keep encodePng(decoded).len + timeIt "pixie decode + alpha": + discard newImage(decodePng(data)) -timeIt "nimPNG decode": - keep decodePNG32(data) + timeIt "pixie encode + alpha": + discard encodePng(decodedImage) + +block: + timeIt "nimPNG decode": + discard decodePNG32(data) -timeIt "nimPNG encode": let decoded = decodePNG32(data) - keep encodePNG32(decoded.data, decoded.width, decoded.height).pixels.len + timeIt "nimPNG encode": + discard encodePNG32(decoded.data, decoded.width, decoded.height) -timeIt "stb_image decode": - var width, height, channels: int - keep loadFromMemory( - cast[seq[byte]](data), - width, - height, - channels, - stbi.RGBA - ) +block: + timeIt "stb_image decode": + var width, height, channels: int + discard loadFromMemory( + cast[seq[byte]](data), + width, + height, + channels, + stbi.RGBA + ) -timeIt "stb_image encode": var width, height, channels: int let decoded = loadFromMemory( cast[seq[byte]](data), @@ -45,16 +49,17 @@ timeIt "stb_image encode": channels, stbi.RGBA ) - keep writePNG(width, height, channels, decoded).len -timeIt "cairo decode": - keep imageSurfaceCreateFromPng(filePath) + timeIt "stb_image encode": + discard writePNG(width, height, channels, decoded).len + +block: + timeIt "cairo decode": + discard imageSurfaceCreateFromPng(filePath) -timeIt "cairo encode": let decoded = imageSurfaceCreateFromPng(filePath) - - var write: WriteFunc = - proc(closure: pointer, data: cstring, len: int32): Status {.cdecl.} = - StatusSuccess - - discard decoded.writeToPng(write, nil) + timeIt "cairo encode": + var write: WriteFunc = + proc(closure: pointer, data: cstring, len: int32): Status {.cdecl.} = + StatusSuccess + discard decoded.writeToPng(write, nil)