Icon representing a recipe

Recipe: Test: ipairs() vs. old style

created by Darkknight900

Profile


Name
Test: ipairs() vs. old style
ID
30988
Shared with
Public
Parent
Test: os.difftime between simple calculation
Children
None
Created on
August 11, 2011 at 11:39 AM UTC
Updated on
August 11, 2011 at 11:39 AM UTC
Description

Here is just a test between the ipairs function and the old style for loops we used.

Best for


Code


p = print a = {} for i = 1, 10000 do a[i] = i end local t1 = os.time() for i, v in ipairs(a) do new = i end local t2 = os.time() p("Time needed: ", t2 - t1) for i = 1, #a do new = i end t3 = os.time() p("Time needed:", t3 - t2)

Comments