Jump to content

Module:User:Mr. Stradivarius/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 05:09, 27 January 2023 (time string library versus mw.ustring). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local iterations = 1000000

return {
	main = function()
		local tick = os.clock()
		for _ = 1, iterations do
			string.match("foo=bar", "=")
		end
		local tock = os.clock()
		mw.log("Time taken: " .. (tock - tick))
		
		tick = os.clock()
		for _ = 1, iterations do
			mw.ustring.match("foo=bar", "=")
		end
		tock = os.clock()
		mw.log("Time taken: " .. (tock - tick))
	end,
}