Advertisement
KananGamer

[TFM-LUA] Performance Testing

Jul 15th, 2018
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. --[[
  2.     { API } Created by: Nettoork#0000
  3.         - Run
  4.             average, loops, function
  5.     { EXAMPLE }
  6.         a = {}
  7.         testPerfomance(10, 100000, function(loop)
  8.             a[#a + 1] = loop
  9.         end)
  10.         a = {}
  11.         testPerfomance(10, 100000, function(loop)
  12.             table.insert(a, loop)
  13.         end)
  14. ]]--
  15.  
  16. --[[    Code    ]]--
  17.  
  18. function testPerfomance(timeLoop, timeLoop2, func)
  19.     local times = 0
  20.     for v = 1, timeLoop do
  21.         local ms = os.time()
  22.         for i = 1, timeLoop2 do
  23.             func(timeLoop2)
  24.         end
  25.         times = times + os.time() - ms
  26.     end
  27.     print('Estimated Time: '..times/timeLoop..' ms.')
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement