This script was based on Xaviar Czervik's & Strife Onizuka's work, which I've modified it for my own purposes over the years, and now has been recreated for LUAU.
Place your line of codes in the "Test Zone" and store any local variables if needed.
--- Ignore this section ---
function time(stamp)
return tonumber(string.sub(stamp, 15, 16)) * 60000 + math.floor((tonumber(string.sub(stamp, 18, -2)) * 1000000.0) / 1000.0)
end
ts0 = ""
ts1 = ""
function state_entry()
end
function touch_start(num_detected)
local i = 0
local max = 1000
---Place your local variables here to prep the stage.---
local Data = "Aacon, Bacon, Cacon, Dacon, Eacon, Facon, Gacon, Hacon, Iacon, Jacon, Kacon, Lacon, Macon"
-------------------------------------------
--- Ignore this section ---
ts0 = ll.GetTimestamp()
repeat
-- TEST ZONE ---------------------------------------------
local ListData = ll.CSV2List(Data)
-- End of Test -------------------------------------------
--- Ignore this section below ---
i = i + 1
until i >= max
ts1 = ll.GetTimestamp()
local elapsed = (time(ts1) - time(ts0)) / max
ll.OwnerSay("Average Time:" .. tostring(elapsed) .. " milliseconds.")
end
state_entry()
For those wondering why I've made these changes...
I removed the framework time calculation because testing showed it was insignificant when exposed to many different elements in a sim that never be truly empty and free of other scripts. Background noise in the simulator can often be greater than FOR loop’s own execution time. LSL’s loop overhead is negligible or often unmeasurable due to the server’s frame rounding. Since not all frames are treated the same, subtracting the framework time from it doesn't provide benefit. It's possible for test code to be smaller when ran on a good frames plus getting a few server rounding, and then have the basic FOR loop counting performs on the worst frames after. Rather not have that contaminates the result.
I also changed how the time() function processes timestamps. Instead of handling the timestamp before and during the test, the script now stores the raw timestamps first, runs the test immediately, store the second timestamp as it finishes, and then processes the timestamp afterward. This ensures minimal interference and keeps string handling out of the test scope. Additionally, I reduced the iteration count from 10,000 to 1,000 since higher counts provided no meaningful improvement in averaging results; just redundant computation.