This commit is contained in:
Ryan Oldenburg 2022-06-03 00:25:53 -05:00
parent 18b814ec65
commit 690250fadd

View file

@ -5,30 +5,35 @@ let
filePath = "tests/fileformats/png/lenna.png" filePath = "tests/fileformats/png/lenna.png"
data = readFile(filePath) data = readFile(filePath)
timeIt "pixie decode": block:
keep decodePngRaw(data) let
decodedPng = decodePng(data)
decodedImage = newImage(decodedPng)
timeIt "pixie encode": timeIt "pixie decode":
let decoded = decodePngRaw(data) discard decodePng(data)
keep encodePng(decoded).len
timeIt "pixie decode + alpha": timeIt "pixie encode":
keep decodePng(data) discard encodePng(decodedPng)
timeIt "pixie encode + alpha": timeIt "pixie decode + alpha":
let decoded = decodePng(data) discard newImage(decodePng(data))
keep encodePng(decoded).len
timeIt "nimPNG decode": timeIt "pixie encode + alpha":
keep decodePNG32(data) discard encodePng(decodedImage)
block:
timeIt "nimPNG decode":
discard decodePNG32(data)
timeIt "nimPNG encode":
let decoded = decodePNG32(data) 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": block:
timeIt "stb_image decode":
var width, height, channels: int var width, height, channels: int
keep loadFromMemory( discard loadFromMemory(
cast[seq[byte]](data), cast[seq[byte]](data),
width, width,
height, height,
@ -36,7 +41,6 @@ timeIt "stb_image decode":
stbi.RGBA stbi.RGBA
) )
timeIt "stb_image encode":
var width, height, channels: int var width, height, channels: int
let decoded = loadFromMemory( let decoded = loadFromMemory(
cast[seq[byte]](data), cast[seq[byte]](data),
@ -45,16 +49,17 @@ timeIt "stb_image encode":
channels, channels,
stbi.RGBA stbi.RGBA
) )
keep writePNG(width, height, channels, decoded).len
timeIt "cairo decode": timeIt "stb_image encode":
keep imageSurfaceCreateFromPng(filePath) discard writePNG(width, height, channels, decoded).len
block:
timeIt "cairo decode":
discard imageSurfaceCreateFromPng(filePath)
timeIt "cairo encode":
let decoded = imageSurfaceCreateFromPng(filePath) let decoded = imageSurfaceCreateFromPng(filePath)
timeIt "cairo encode":
var write: WriteFunc = var write: WriteFunc =
proc(closure: pointer, data: cstring, len: int32): Status {.cdecl.} = proc(closure: pointer, data: cstring, len: int32): Status {.cdecl.} =
StatusSuccess StatusSuccess
discard decoded.writeToPng(write, nil) discard decoded.writeToPng(write, nil)