imgA-simple: bench block for qoi / tga / ppm / hdr (append-only at the end of tools/bench.luau)
This commit is contained in:
1 parent
4dab50793f
commit
4766753ad8
1 file changed
+40
@@ -56,3 +56,43 @@ do
|
||||
Png.encode(img)
|
||||
end)
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ imgA-simple: qoi / tga / pnm / hdr
|
||||
-- fixtures: tools/fixtures/qoi.py (tests/gen/qoi_bench.luau: run python3 -I tools/fixtures.py qoi first)
|
||||
do
|
||||
local Qoi = require("@formats/image/qoi")
|
||||
local Tga = require("@formats/image/tga")
|
||||
local Pnm = require("@formats/image/pnm")
|
||||
local Hdr = require("@formats/image/hdr")
|
||||
local Types = require("@formats/Types")
|
||||
local QB = require("@tests/gen/qoi_bench")
|
||||
local qd = buffer.fromstring(QB.data)
|
||||
local n = QB.width * QB.height * 4
|
||||
bench("qoi decode 1024x768", 5, n, function()
|
||||
Qoi.decode(Bytes.reader(qd))
|
||||
end)
|
||||
local img = Types.Image.new(QB.width, QB.height)
|
||||
img.pixels = buffer.fromstring(QB.pixels)
|
||||
bench("qoi encode 1024x768", 5, n, function()
|
||||
Qoi.encode(img)
|
||||
end)
|
||||
local tr = Tga.encode(img, { rle = true }) :: buffer
|
||||
bench("tga decode rle 1024x768", 3, n, function()
|
||||
Tga.decode(Bytes.reader(tr))
|
||||
end)
|
||||
bench("tga encode rle 1024x768", 3, n, function()
|
||||
Tga.encode(img, { rle = true })
|
||||
end)
|
||||
local pp = Pnm.encode(img, { format = "ppm" }) :: buffer
|
||||
bench("ppm decode 1024x768", 3, n, function()
|
||||
Pnm.decode(Bytes.reader(pp))
|
||||
end)
|
||||
local f = Hdr.decode(Bytes.reader(Hdr.encode(img) :: buffer), { native = true }) :: Types.Image
|
||||
local hb = Hdr.encode(f) :: buffer
|
||||
bench("hdr decode rle 1024x768 (rgbaf32)", 3, n, function()
|
||||
Hdr.decode(Bytes.reader(hb), { native = true })
|
||||
end)
|
||||
bench("hdr encode rle 1024x768", 3, n, function()
|
||||
Hdr.encode(f)
|
||||
end)
|
||||
end
|
||||
Reference in new issue
Block a user