ws-m4a: merge ws/absorb (audio/opus, containers/Ogg, ...) for the CELT encoder; m4a fixtures load their helper by path (tools/fixtures/ on sys.path shadowed the xml package)
This commit is contained in:
commit
29a95ce24f
215 files changed
+24209
-61
No files matched your search
+90
-1
@@ -1,11 +1,23 @@
|
||||
-- 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), tools/fixtures/mp3.py,
|
||||
-- tools/fixtures/opus.py (3 s stereo files; MB/s of f32 output, 48 kHz stereo f32 is 0.384 MB/s of real time),
|
||||
-- tools/fixtures/flac.py; wav encodes / decodes a generated tone.
|
||||
local Deflate = require("@formats/codecs/Deflate")
|
||||
local Crc32 = require("@formats/core/Crc32")
|
||||
local Bytes = require("@formats/core/Bytes")
|
||||
local Png = require("@formats/image/png")
|
||||
local B = require("@tests/gen/deflate_bench")
|
||||
local PB = require("@tests/gen/png_bench")
|
||||
local Mp3 = require("@formats/audio/mp3")
|
||||
local MC = require("@tests/gen/mp3_cases")
|
||||
local Opus = require("@formats/audio/opus")
|
||||
local OpusCelt = require("@tests/gen/opus_celt_st_128")
|
||||
local OpusSilk = require("@tests/gen/opus_silk_wb_st")
|
||||
local OpusHybrid = require("@tests/gen/opus_hybrid_st")
|
||||
local Flac = require("@formats/audio/flac")
|
||||
local FC = require("@tests/gen/flac_cases")
|
||||
local Wav = require("@formats/audio/wav")
|
||||
local Types = require("@formats/Types")
|
||||
|
||||
local runtime = if (_G :: any).jit ~= nil then "luajit" else "luau"
|
||||
|
||||
@@ -18,6 +30,7 @@ local function bench(label: string, n: number, bytes: number, f: () -> ())
|
||||
dt = math.min(dt, os.clock() - t0)
|
||||
end
|
||||
print(string.format("%-8s %-30s %8.2f ms %7.1f MB/s", runtime, label, dt * 1000, bytes / dt / 1e6))
|
||||
return dt
|
||||
end
|
||||
|
||||
local z = buffer.fromstring(B.zlib)
|
||||
@@ -56,6 +69,82 @@ do
|
||||
Png.encode(img)
|
||||
end)
|
||||
end
|
||||
for _, name in { "l3_cbr128_js", "l3_vbr_v2_48k", "l2_192_st" } do
|
||||
for _, c in MC do
|
||||
if c.name == name then
|
||||
local b = buffer.fromstring(c.data)
|
||||
local dec = assert(Mp3.open(Bytes.reader(b)))
|
||||
local secs = dec.duration
|
||||
local dt = bench("mp3 decode " .. name, 5, dec.frames * dec.channels * 4, function()
|
||||
local d = assert(Mp3.open(Bytes.reader(b)))
|
||||
d:readAll()
|
||||
end)
|
||||
print(string.format("%-8s %-30s %8.0fx real time", runtime, "", secs / dt))
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, c in { { "celt 128k", OpusCelt }, { "silk wb", OpusSilk }, { "hybrid", OpusHybrid } } do
|
||||
local b = buffer.fromstring(c[2].data)
|
||||
bench("opus decode " .. c[1] .. " (3 s st)", 3, #c[2].ref, function()
|
||||
Opus.decode(Bytes.reader(b))
|
||||
end)
|
||||
end
|
||||
for _, name in { "s16_long", "s24_96k" } do
|
||||
for _, c in FC do
|
||||
if c.name == name then
|
||||
local b = buffer.fromstring(c.data)
|
||||
local dec = assert(Flac.open(Bytes.reader(b)))
|
||||
local secs = dec.duration
|
||||
local dt = bench("flac decode " .. name, 5, dec.frames * dec.channels * 4, function()
|
||||
Flac.decode(Bytes.reader(b))
|
||||
end)
|
||||
print(string.format("%-8s %-30s %8.0fx real time", runtime, "", secs / dt))
|
||||
end
|
||||
end
|
||||
end
|
||||
do
|
||||
local a = Types.Audio.new(44100, 2, 44100 * 10)
|
||||
for i = 0, 44100 * 20 - 1 do
|
||||
buffer.writef32(a.samples, i * 4, math.sin(i * 0.01) * 0.5)
|
||||
end
|
||||
bench("wav encode s16 (10 s stereo)", 5, buffer.len(a.samples), function()
|
||||
Wav.encode(a)
|
||||
end)
|
||||
local file = assert(Wav.encode(a))
|
||||
bench("wav decode s16 (10 s stereo)", 5, buffer.len(a.samples), function()
|
||||
Wav.decode(Bytes.reader(file))
|
||||
end)
|
||||
end
|
||||
do
|
||||
local Json = require("@formats/codecs/Json")
|
||||
local JB = require("@tests/gen/json_bench")
|
||||
local v = assert(Json.decode(JB.text))
|
||||
assert(Json.encode(v) == JB.compact, "json bench mismatch")
|
||||
bench("json decode (indented)", 5, #JB.text, function()
|
||||
Json.decode(JB.text)
|
||||
end)
|
||||
bench("json decode (compact)", 5, #JB.compact, function()
|
||||
Json.decode(JB.compact)
|
||||
end)
|
||||
bench("json encode (compact, sorted)", 5, #JB.compact, function()
|
||||
Json.encode(v)
|
||||
end)
|
||||
end
|
||||
do
|
||||
local Xml = require("@formats/codecs/Xml")
|
||||
local XB = require("@tests/gen/xml_bench")
|
||||
local doc = assert(Xml.decode(XB.text))
|
||||
bench("xml decode (DOM)", 5, #XB.text, function()
|
||||
Xml.decode(XB.text)
|
||||
end)
|
||||
bench("xml events", 5, #XB.text, function()
|
||||
for _ in Xml.events(XB.text) do
|
||||
end
|
||||
end)
|
||||
bench("xml encode", 5, #XB.text, function()
|
||||
Xml.encode(doc)
|
||||
end)
|
||||
end
|
||||
|
||||
-- ws-m4a: AAC-LC / ALAC decode and ALAC encode (MB/s of 16-bit PCM equivalent: frames * channels * 2), MDCT
|
||||
do
|
||||
|
||||
Reference in new issue
Block a user