pixie/tests/benchmark_png.nim

40 lines
899 B
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,
2020-12-04 06:44:44 +00:00
benchy, 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-12-04 06:44:44 +00:00
keep decodePng(cast[seq[uint8]](data))
2020-11-21 02:21:27 +00:00
2020-11-23 04:01:56 +00:00
timeIt "pixie encode":
let decoded = decodePng(cast[seq[uint8]](data))
2020-12-04 06:44:44 +00:00
keep encodePng(decoded).len
2020-11-23 04:01:56 +00:00
timeIt "nimPNG decode":
2020-12-04 06:44:44 +00:00
keep decodePNG32(data)
2020-11-21 02:21:27 +00:00
2020-11-23 04:01:56 +00:00
timeIt "nimPNG encode":
let decoded = decodePNG32(data)
2020-12-04 06:44:44 +00:00
keep encodePNG32(decoded.data, decoded.width, decoded.height).pixels.len
2020-11-23 04:01:56 +00:00
timeIt "stb_image decode":
2020-12-04 06:44:44 +00:00
var width, height, channels: int
keep 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
)
2020-12-04 06:44:44 +00:00
keep writePNG(width, height, channels, decoded).len