better png benchmark, use bestspeed

This commit is contained in:
Ryan Oldenburg 2020-11-22 22:01:56 -06:00
parent 278cb4533e
commit d5e977b6b2
18 changed files with 28 additions and 5 deletions

View file

@ -469,7 +469,7 @@ proc encodePng*(
let compressed =
try:
compress(filtered, DefaultCompression, dfZlib)
compress(filtered, BestSpeed, dfZlib)
except ZippyError:
raise newException(
PixieError, "Unexpected error compressing PNG image data"

View file

@ -1,16 +1,27 @@
import pixie/fileformats/png, stb_image/read as stbi, fidget/opengl/perf, nimPNG
import pixie/fileformats/png, stb_image/read as stbi, stb_image/write as stbr,
fidget/opengl/perf, nimPNG
let data = readFile("tests/data/lenna.png")
timeIt "pixie":
timeIt "pixie decode":
for i in 0 ..< 100:
discard decodePng(cast[seq[uint8]](data))
timeIt "nimPNG":
timeIt "pixie encode":
let decoded = decodePng(cast[seq[uint8]](data))
for i in 0 ..< 1:
discard encodePng(decoded).len
timeIt "nimPNG decode":
for i in 0 ..< 100:
discard decodePNG32(data)
timeIt "stb_image":
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":
for i in 0 ..< 100:
var width, height, channels: int
discard loadFromMemory(
@ -20,3 +31,15 @@ timeIt "stb_image":
channels,
stbi.RGBA
)
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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 343 B

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 343 B

After

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB