ws-webp: codec tests (vp8, vp8l), bench lines, type fixes

This commit is contained in:
4DBug committed 2026-10-31 08:58:17 -05:00
1 parent 7c3d4b75ec
commit 5977b60df6
7 files changed
+226 -5

No files matched your search

+21 -1
View File
@@ -1,5 +1,6 @@
-- Throughput (bash tools/bench.sh): codec MB/s under both runtimes. MB/s are of decompressed output, best of n runs.
-- Fixtures: tools/fixtures/deflate.py (a 6 MB corpus) and tools/fixtures/png.py (1024 x 768 images).
-- Fixtures: tools/fixtures/deflate.py (a 6 MB corpus), tools/fixtures/png.py (1024 x 768 images) and
-- tools/fixtures/webp.py (512 x 512 lossy and lossless files).
local Deflate = require("@formats/codecs/Deflate")
local Crc32 = require("@formats/core/Crc32")
local Bytes = require("@formats/core/Bytes")
@@ -56,3 +57,22 @@ do
Png.encode(img)
end)
end
do
local Webp = require("@formats/image/webp")
local WB = require("@tests/gen/webp_bench")
local n = WB.width * WB.height * 4
local lossy, lossless = buffer.fromstring(WB.lossy), buffer.fromstring(WB.lossless)
bench("webp lossy decode 512x512", 3, n, function()
Webp.decode(Bytes.reader(lossy))
end)
bench("webp lossless decode 512x512", 3, n, function()
Webp.decode(Bytes.reader(lossless))
end)
local img = assert(Webp.decode(Bytes.reader(lossless)))
bench("webp lossless encode (effort 5)", 1, n, function()
Webp.encode(img)
end)
bench("webp lossless encode (effort 1)", 1, n, function()
Webp.encode(img, { effort = 1 })
end)
end
+1 -1
View File
@@ -3,7 +3,7 @@
cd "$(dirname "$0")/.." || exit 1
LUAU=${LUAU:-$(command -v luau || nix shell nixpkgs#luau -c sh -c 'command -v luau')}
LUAJIT=${LUAJIT:-$(command -v luajit || nix shell nixpkgs#luajit -c sh -c 'command -v luajit')}
python3 -I tools/fixtures.py deflate png > /dev/null || exit 1
python3 -I tools/fixtures.py deflate png webp > /dev/null || exit 1
python3 -I tools/build.py luajit > /dev/null || exit 1
"$LUAU" --codegen -O2 tools/bench.luau
"$LUAJIT" -e 'package.path = "build/luajit/?.lua;build/luajit/?/init.lua;" .. package.path' build/luajit/tools/bench.lua