From a4d6e79fa48e53dabcc4f6df68c303093465be10 Mon Sep 17 00:00:00 2001 From: 4DBug Date: Sat, 31 Oct 2026 08:51:47 -0500 Subject: [PATCH] imgA-tiff: bench block (decode / encode none, lzw, deflate; rgba16) --- tools/bench.luau | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/bench.luau b/tools/bench.luau index 9f6aef7..8b27f59 100644 --- a/tools/bench.luau +++ b/tools/bench.luau @@ -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