luau/bench/micro_tests/test_TableSort.lua
Lily Brown 551a43c424
Sync to upstream/release/593 (#1024)
- Updated Roblox copyright to 2023
- Floor division operator `//` (implements #832)
- Autocomplete now shows `end` within `do` blocks
- Restore BraceType when using `Lexer::lookahead` (fixes #1019)

# New typechecker

- Subtyping tests between metatables and tables
- Subtyping tests between string singletons and tables
- Subtyping tests for class types

# Native codegen

- Fixed macOS test failure (wrong spill restore offset)
- Fixed clobbering of non-volatile xmm registers on Windows
- Fixed wrong storage location of SSA reg spills
- Implemented A64 support for add/sub extended
- Eliminated zextReg from A64 lowering
- Remove identical table slot lookups
- Propagate values from predecessor into the linear block
- Disabled reuse slot optimization
- Keep `LuaNode::val` check for nil when optimizing `CHECK_SLOT_MATCH`
- Implemented IR translation of `table.insert` builtin
- Fixed mmap error handling on macOS/Linux

# Tooling

- Used `|` as a column separator instead of `+` in `bench.py`
- Added a `table.sort` micro-benchmark
- Switched `libprotobuf-mutator` to a less problematic version
2023-09-01 10:58:27 -07:00

22 lines
715 B
Lua

local bench = script and require(script.Parent.bench_support) or require("bench_support")
local arr_months = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}
local arr_num = {}
for i=1,100 do table.insert(arr_num, math.sin(i)) end
local arr_numk = {}
for i=1,10000 do table.insert(arr_numk, math.sin(i)) end
function test(arr)
local t = table.create(#arr)
for i=1,1e6/#arr do
table.move(arr, 1, #arr, 1, t)
table.sort(t)
end
end
bench.runCode(function() test(arr_months) end, "table.sort: 12 strings")
bench.runCode(function() test(arr_num) end, "table.sort: 100 numbers")
bench.runCode(function() test(arr_numk) end, "table.sort: 10k numbers")