merge master into ws/arch2
This commit is contained in:
commit
0ee0859298
64 files changed
+13113
-30
No files matched your search
@@ -249,6 +249,40 @@ do
|
||||
Lz4.compress(raw)
|
||||
end)
|
||||
end
|
||||
-- ws-roblox: a model of 20000 parts (built here) through model/rbxm and model/rbxmx, and a .mesh decode
|
||||
do
|
||||
local Rbx = require("@formats/codecs/model/Rbx")
|
||||
local Rbxm = require("@formats/model/rbxm")
|
||||
local Rbxmx = require("@formats/model/rbxmx")
|
||||
local RobloxMesh = require("@formats/model/robloxmesh")
|
||||
local tree = Rbx.tree()
|
||||
local folder = Rbx.add(tree, Rbx.instance("Folder", "Parts"))
|
||||
for i = 1, 20000 do
|
||||
local p = Rbx.add(folder, Rbx.instance("Part", "P" .. i))
|
||||
Rbx.set(p, "CFrame", "CFrame", { i, i % 7, -i, 1, 0, 0, 0, 1, 0, 0, 0, 1 })
|
||||
Rbx.set(p, "size", "Vector3", { 4, 1, 2 + i % 3 })
|
||||
Rbx.set(p, "Color3uint8", "Color3uint8", { i % 256, 128, 255 - i % 256 })
|
||||
Rbx.set(p, "Anchored", "Bool", i % 2 == 0)
|
||||
Rbx.set(p, "Transparency", "Float32", (i % 4) / 4)
|
||||
Rbx.set(p, "Material", "Enum", 256)
|
||||
end
|
||||
local bin = Rbxm.encode(tree) :: buffer
|
||||
local xml = Rbxmx.encode(tree) :: buffer
|
||||
bench("rbxm decode (20k parts)", 3, buffer.len(bin), function()
|
||||
Rbxm.decode(Bytes.reader(bin))
|
||||
end)
|
||||
bench("rbxm encode (20k parts)", 3, buffer.len(bin), function()
|
||||
Rbxm.encode(tree)
|
||||
end)
|
||||
bench("rbxmx decode (20k parts)", 3, buffer.len(xml), function()
|
||||
Rbxmx.decode(Bytes.reader(xml))
|
||||
end)
|
||||
local M = require("@tests/gen/robloxmesh")
|
||||
local mesh = buffer.fromstring(M.cases[#M.cases - 1].data)
|
||||
bench("robloxmesh decode (v7, skinned)", 20, buffer.len(mesh), function()
|
||||
RobloxMesh.decode(Bytes.reader(mesh))
|
||||
end)
|
||||
end
|
||||
do
|
||||
local Brotli = require("@formats/codecs/compress/Brotli")
|
||||
local BB = require("@tests/gen/brotli_bench")
|
||||
@@ -1143,3 +1177,81 @@ do
|
||||
end
|
||||
end
|
||||
end
|
||||
do
|
||||
-- NBT / voxels (ws-voxel): a chunk-like NBT tree (24 sections with packed long arrays, 4000 entity-like compounds)
|
||||
-- through codecs/text/Nbt (binary and SNBT), 1M packed 5-bit indices, a 64^3 Sponge schematic and Qubicle file
|
||||
local Nbt = require("@formats/codecs/text/Nbt")
|
||||
local Mc = require("@formats/codecs/model/Minecraft")
|
||||
local Schematic = require("@formats/model/schematic")
|
||||
local Qb = require("@formats/model/qb")
|
||||
local sections = Nbt.list("compound")
|
||||
for s = 1, 24 do
|
||||
local pal = Nbt.list("compound")
|
||||
for p = 1, 16 do
|
||||
table.insert(pal, Nbt.compound({ Name = "minecraft:block_" .. p, Properties = Nbt.compound({ axis = "y" }, { "axis" }) }, { "Name", "Properties" }))
|
||||
end
|
||||
local longs = buffer.create(256 * 8)
|
||||
for i = 0, 511 do
|
||||
buffer.writeu32(longs, i * 4, (i * 2654435761) % 4294967296)
|
||||
end
|
||||
table.insert(sections, Nbt.compound({ Y = Nbt.byte(s - 5), block_states = Nbt.compound({ palette = pal, data = Nbt.longArray(longs) }, { "palette", "data" }) }, { "Y", "block_states" }))
|
||||
end
|
||||
local ents = Nbt.list("compound")
|
||||
for i = 1, 4000 do
|
||||
table.insert(ents, Nbt.compound({
|
||||
id = "minecraft:thing",
|
||||
Pos = Nbt.list("double", { Nbt.double(i * 0.5), Nbt.double(64), Nbt.double(-i * 0.25) }),
|
||||
Health = Nbt.float(20),
|
||||
UUID = Nbt.intArray({ i, -i, i * 3, 7 }),
|
||||
Tags = Nbt.list("string", { "a", "b" }),
|
||||
Age = Nbt.short(i % 1000),
|
||||
Seed = Nbt.long(i * 1234567),
|
||||
}, { "id", "Pos", "Health", "UUID", "Tags", "Age", "Seed" }))
|
||||
end
|
||||
local root = Nbt.compound({ DataVersion = 3953, sections = sections, entities = ents }, { "DataVersion", "sections", "entities" })
|
||||
local raw = assert(Nbt.encode(root, { compression = "none" }))
|
||||
bench("nbt decode (" .. buffer.len(raw) // 1000 .. " KB)", 5, buffer.len(raw), function()
|
||||
Nbt.decode(raw)
|
||||
end)
|
||||
bench("nbt encode", 5, buffer.len(raw), function()
|
||||
Nbt.encode(root, { compression = "none" })
|
||||
end)
|
||||
local text = assert(Nbt.print(root))
|
||||
bench("snbt parse (" .. #text // 1000 .. " KB)", 3, #text, function()
|
||||
Nbt.parse(text)
|
||||
end)
|
||||
bench("snbt print", 3, #text, function()
|
||||
Nbt.print(root)
|
||||
end)
|
||||
local n = 1048576
|
||||
local idx = buffer.create(n * 2)
|
||||
for i = 0, n - 1 do
|
||||
buffer.writeu16(idx, i * 2, (i * 7) % 32)
|
||||
end
|
||||
local packed = Mc.Packed.pack(idx, n, 5, false)
|
||||
local out = buffer.create(n * 2)
|
||||
bench("packed unpack 1M x 5 bits (MB out)", 5, n * 2, function()
|
||||
Mc.Packed.unpack(packed, 5, n, false, out, 32)
|
||||
end)
|
||||
local V = 64
|
||||
local states = { "minecraft:air" }
|
||||
for i = 1, 40 do
|
||||
table.insert(states, "minecraft:block_" .. i)
|
||||
end
|
||||
local cells = buffer.create(V * V * V * 2)
|
||||
for i = 0, V * V * V - 1 do
|
||||
buffer.writeu16(cells, i * 2, if (i // V) % 3 == 0 then 0 else 1 + (i // 97) % 40)
|
||||
end
|
||||
local grid = Mc.voxels(V, V, V, states, cells)
|
||||
local schem = assert(Schematic.encode(grid, { compression = "none" }))
|
||||
bench("schem decode 64^3 (MB of cells)", 3, V * V * V, function()
|
||||
Schematic.decode(Bytes.reader(schem))
|
||||
end)
|
||||
bench("schem encode 64^3", 3, V * V * V, function()
|
||||
Schematic.encode(grid, { compression = "none" })
|
||||
end)
|
||||
local qb = assert(Qb.encode(grid))
|
||||
bench("qb decode 64^3 rle (MB of cells)", 3, V * V * V, function()
|
||||
Qb.decode(Bytes.reader(qb))
|
||||
end)
|
||||
end
|
||||
Reference in new issue
Block a user