luau/bench/micro_tests/test_StringInterp.lua
vegorov-rbx d98256bb80
Sync to upstream/release/590 (#1008)
* Better indentation in multi-line type mismatch error messages
* Error message clone can no longer cause a stack overflow (when
typechecking with retainFullTypeGraphs set to false); fixes
https://github.com/Roblox/luau/issues/975
* `string.format` with %s is now ~2x faster on strings smaller than 100
characters

Native code generation:
* All VM side exits will block return to the native execution of the
current function to preserve correctness
* Fixed executable page allocation on Apple platforms when using
hardened runtime
* Added statistics for code generation (no. of functions compiler,
memory used for different areas)
* Fixed issue with function entry type checks performed more that once
in some functions
2023-08-11 07:42:37 -07:00

51 lines
No EOL
1 KiB
Lua

local bench = script and require(script.Parent.bench_support) or require("bench_support")
bench.runCode(function()
for j=1,1e6 do
local _ = "j=" .. tostring(j)
end
end, "interp: tostring")
bench.runCode(function()
for j=1,1e6 do
local _ = "j=" .. j
end
end, "interp: concat")
bench.runCode(function()
for j=1,1e6 do
local _ = string.format("j=%f", j)
end
end, "interp: %f format")
bench.runCode(function()
for j=1,1e6 do
local _ = string.format("j=%d", j)
end
end, "interp: %d format")
bench.runCode(function()
for j=1,1e6 do
local _ = string.format("j=%*", j)
end
end, "interp: %* format")
bench.runCode(function()
for j=1,1e6 do
local _ = `j={j}`
end
end, "interp: interp number")
bench.runCode(function()
local ok = "hello!"
for j=1,1e6 do
local _ = string.format("j=%s", ok)
end
end, "interp: %s format")
bench.runCode(function()
local ok = "hello!"
for j=1,1e6 do
local _ = `j={ok}`
end
end, "interp: interp string")