ws-arch: bench lines for zstd / brotli / bzip2 / xz / lzma and glyph outline + rasterize throughput; bench.sh builds their fixtures
This commit is contained in:
1 parent
6226ec41e4
commit
ef402142f1
2 files changed
+77
-2
No files matched your search
+76
-1
@@ -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), zstd / brotli /
|
||||
-- bzip2 / lzma (their *_bench corpora) and fonts (glyph outlines + rasterization: glyphs per second).
|
||||
local Deflate = require("@formats/codecs/Deflate")
|
||||
local Crc32 = require("@formats/core/Crc32")
|
||||
local Bytes = require("@formats/core/Bytes")
|
||||
@@ -56,3 +57,77 @@ do
|
||||
Png.encode(img)
|
||||
end)
|
||||
end
|
||||
|
||||
-- ws-arch codecs: zstd, brotli, bzip2, xz / lzma
|
||||
do
|
||||
local Zstd = require("@formats/codecs/Zstd")
|
||||
local ZB = require("@tests/gen/zstd_bench")
|
||||
local z3, z19 = buffer.fromstring(ZB.data3), buffer.fromstring(ZB.data19)
|
||||
local zo = assert(Zstd.decompress(z3))
|
||||
assert(buffer.len(zo) == ZB.size and Crc32.of(zo) == ZB.crc, "zstd bench corpus mismatch")
|
||||
bench("zstd -3 (+ xxh64)", 3, ZB.size, function()
|
||||
Zstd.decompress(z3)
|
||||
end)
|
||||
bench("zstd -3 (no checksum)", 3, ZB.size, function()
|
||||
Zstd.decompress(z3, nil, nil, { verify = false })
|
||||
end)
|
||||
bench("zstd -19 (no checksum)", 3, ZB.size, function()
|
||||
Zstd.decompress(z19, nil, nil, { verify = false })
|
||||
end)
|
||||
end
|
||||
do
|
||||
local Brotli = require("@formats/codecs/Brotli")
|
||||
local BB = require("@tests/gen/brotli_bench")
|
||||
local bz = buffer.fromstring(BB.data)
|
||||
local bout = assert(Brotli.decompress(bz))
|
||||
assert(buffer.len(bout) == BB.size and Crc32.of(bout) == BB.crc, "brotli bench corpus mismatch")
|
||||
bench("brotli decompress (q9 w22)", 5, BB.size, function()
|
||||
Brotli.decompress(bz)
|
||||
end)
|
||||
end
|
||||
do
|
||||
local Bzip2 = require("@formats/codecs/Bzip2")
|
||||
local BZ = require("@tests/gen/bzip2_bench")
|
||||
local bz = buffer.fromstring(BZ.data)
|
||||
bench("bzip2 decompress -9", 3, BZ.size, function()
|
||||
Bzip2.decompress(bz)
|
||||
end)
|
||||
end
|
||||
do
|
||||
local Lzma = require("@formats/codecs/Lzma")
|
||||
local LB = require("@tests/gen/lzma_bench")
|
||||
local lx, la = buffer.fromstring(LB.xz), buffer.fromstring(LB.alone)
|
||||
local lo = assert(Lzma.xz(lx))
|
||||
assert(buffer.len(lo) == LB.size and Crc32.of(lo) == LB.crc, "lzma bench corpus mismatch")
|
||||
bench("xz -6 (lzma2 + crc64)", 3, LB.size, function()
|
||||
Lzma.xz(lx)
|
||||
end)
|
||||
bench("lzma alone -6", 3, LB.size, function()
|
||||
Lzma.alone(la)
|
||||
end)
|
||||
end
|
||||
|
||||
-- fonts: outlines and rasterization (MB/s here = thousands of glyphs per second)
|
||||
do
|
||||
local Ttf = require("@formats/font/ttf")
|
||||
local FX = require("@tests/gen/fonts")
|
||||
for _, c in FX.fonts do
|
||||
if c.name == "Roboto-Medium" or c.name == "SourceSans3-Regular" then
|
||||
local f = assert(Ttf.decode(Bytes.reader(buffer.fromstring(c.data))))
|
||||
local gl = {}
|
||||
for cp = 33, 126 do
|
||||
table.insert(gl, f:glyphIndex(cp))
|
||||
end
|
||||
bench(c.name .. " outlines (kglyph/s)", 3, #gl * 1000, function()
|
||||
for _, g in gl do
|
||||
f:outline(g)
|
||||
end
|
||||
end)
|
||||
bench(c.name .. " rasterize 32 px (kglyph/s)", 3, #gl * 1000, function()
|
||||
for _, g in gl do
|
||||
f:rasterize(g, 32)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
+1
-1
@@ -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 zstd brotli bzip2 lzma fonts > /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
|
||||
Reference in new issue
Block a user