-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathLuaPerformanceTest.lua
More file actions
30 lines (24 loc) · 920 Bytes
/
LuaPerformanceTest.lua
File metadata and controls
30 lines (24 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
local print = print
local math_sqrt = math.sqrt
local system_getTimer = GetTickCount()
local function test(iterations)
local time = 0
local totalTime = 0
local testStart = GetTickCount()
for i = 1, iterations do
local startTime = GetTickCount()
for i = 1, 1000000 do
--local t = 100 ^ 0.5
local t = math_sqrt(100)
end
local testTime = GetTickCount() - startTime
time = time + testTime
end
time = time / iterations -- Average the result
totalTime = GetTickCount() - testStart
local result = "\n\nTest Finished: \n\t" .. iterations * 1000000 .. " calculations\n\t" .. totalTime / 1000 .. " secs taken\n\t" .. time .. " ms on average"
print(result)
end
for i = 1, 4 do
test(50)
end