imgA-tiff: bench block (decode / encode none, lzw, deflate; rgba16)

This commit is contained in:
4DBug committed 2026-10-31 08:51:47 -05:00
1 parent bb30922385
commit b56fa55785
1 file changed
+24
+24
View File
@@ -56,3 +56,27 @@ do
Png.encode(img)
end)
end
-- ------------------------------------------------------------------------------------------------ image/tiff (ws-imgA)
do
local Tiff = require("@formats/image/tiff")
local Types = require("@formats/Types")
local src = Types.Image.new(1024, 768)
for i = 0, 1024 * 768 - 1 do
local x, y = i % 1024, i // 1024
buffer.writeu32(src.pixels, i * 4, 0xFF000000 + (x % 256) + ((y % 256) * 256) + (((x + y) // 4 % 256) * 65536))
end
for _, comp in { "none", "lzw", "deflate" } do
local enc = Tiff.encode(src, { compression = comp :: any }) :: buffer
bench("tiff decode rgba8 " .. comp, 3, 1024 * 768 * 4, function()
Tiff.decode(Bytes.reader(enc))
end)
bench("tiff encode rgba8 " .. comp, 2, 1024 * 768 * 4, function()
Tiff.encode(src, { compression = comp :: any })
end)
end
local enc16 = Tiff.encode(Types.Image.new(1024, 768, "rgba16"), { compression = "lzw" }) :: buffer
bench("tiff decode rgba16 lzw -> rgba8", 3, 1024 * 768 * 8, function()
Tiff.decode(Bytes.reader(enc16))
end)
end