pixie/tests/benchmark_png.nim

46 lines
1.1 KiB
Nim
Raw Normal View History

2020-11-23 04:01:56 +00:00
import pixie/fileformats/png, stb_image/read as stbi, stb_image/write as stbr,
fidget/opengl/perf, nimPNG
2020-11-21 02:21:27 +00:00
2020-11-29 03:34:24 +00:00
let data = readFile("tests/images/png/lenna.png")
2020-11-21 02:21:27 +00:00
2020-11-23 04:01:56 +00:00
timeIt "pixie decode":
2020-11-21 02:21:27 +00:00
for i in 0 ..< 100:
discard decodePng(cast[seq[uint8]](data))
2020-11-23 04:01:56 +00:00
timeIt "pixie encode":
let decoded = decodePng(cast[seq[uint8]](data))
for i in 0 ..< 1:
discard encodePng(decoded).len
timeIt "nimPNG decode":
2020-11-21 02:21:27 +00:00
for i in 0 ..< 100:
discard decodePNG32(data)
2020-11-23 04:01:56 +00:00
timeIt "nimPNG encode":
let decoded = decodePNG32(data)
for i in 0 ..< 100:
discard encodePNG32(decoded.data, decoded.width, decoded.height).pixels.len
timeIt "stb_image decode":
2020-11-21 02:21:27 +00:00
for i in 0 ..< 100:
var width, height, channels: int
discard loadFromMemory(
cast[seq[byte]](data),
width,
height,
channels,
stbi.RGBA
)
2020-11-23 04:01:56 +00:00
timeIt "stb_image encode":
var width, height, channels: int
let decoded = loadFromMemory(
cast[seq[byte]](data),
width,
height,
channels,
stbi.RGBA
)
for i in 0 ..< 100:
discard writePNG(width, height, channels, decoded).len