luau/bench/micro_tests/test_string_lib.lua
Arseny Kapoulkine d01addc625 Sync to upstream/release/501 (#20)
Co-authored-by: Rodactor <rodactor@roblox.com>
2021-11-01 14:52:34 -07:00

39 lines
875 B
Lua

local bench = script and require(script.Parent.bench_support) or require("bench_support")
bench.runCode(function()
local src = string.rep("abcdefghijklmnopqrstuvwxyz", 100)
local str = ""
for i=1,1000 do
str = string.upper(src)
str = string.reverse(str)
str = string.lower(str)
end
assert(#str)
end, "string: reverse/upper/lower (large)")
bench.runCode(function()
local str = ""
for i=1,100000 do
src = "abcdefghijklmnopqrstuvwxyz" .. i
str = string.upper(src)
str = string.reverse(str)
str = string.lower(str)
end
assert(#str)
end, "string: reverse/upper/lower (unique)")
bench.runCode(function()
local str = ""
for i=1,1000000 do
str = string.rep("_", 19)
end
assert(#str)
end, "string: rep (small)")
bench.runCode(function()
local str = ""
for i=1,100 do
str = string.rep("abcd", 100000)
end
assert(#str)
end, "string: rep (large)")