Created
January 30, 2012 03:20
-
-
Save Deco/1702276 to your computer and use it in GitHub Desktop.
select(arg_i, ...) vs ({...})[arg_i]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--jit.off(true, true) | |
local r = 3000 | |
do local t = os.clock() local v = 0 | |
local function f(...) | |
local s = "" | |
for arg_i = 1, select('#', ...) do | |
s = s..tostring(select(arg_i, ...)) | |
end | |
return s | |
end | |
for i = 1, r do | |
v = v+#f( | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7 | |
) | |
end | |
print(v, os.clock()-t) | |
end | |
collectgarbage() | |
do local t = os.clock() local v = 0 | |
local function f(...) | |
local s = "" | |
local arg = {...} | |
for arg_i = 1, #arg do | |
s = s..tostring(arg[arg_i]) | |
end | |
return s | |
end | |
for i = 1, r do | |
v = v+#f( | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
7, 7, 7, 7 | |
) | |
end | |
collectgarbage() | |
print(v, os.clock()-t) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select: 684000 1.1670000000013 | |
tables: 684000 0.61299999999756 | |
select: 684000 1.1729999999952 | |
tables: 684000 0.64100000000326 | |
select: 684000 1.176999999996 | |
tables: 684000 0.63500000000931 | |
select: 684000 1.1710000000021 | |
tables: 684000 0.63799999999173 | |
select: 684000 1.1719999999914 | |
tables: 684000 0.63199999999779 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select: 684000 0.632 | |
tables: 684000 0.466 | |
select: 684000 0.632 | |
tables: 684000 0.47 | |
select: 684000 0.635 | |
tables: 684000 0.471 | |
select: 684000 0.635 | |
tables: 684000 0.471 | |
select: 684000 0.636 | |
tables: 684000 0.469 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select: 420000 0.35199999999999 | |
tables: 420000 0.279 | |
select: 420000 0.351 | |
tables: 420000 0.282 | |
select: 420000 0.36199999999999 | |
tables: 420000 0.28 | |
select: 420000 0.35000000000001 | |
tables: 420000 0.27999999999999 | |
select: 420000 0.35000000000001 | |
tables: 420000 0.28 | |
(Note: The number of arguments had to be reduced from 258 to 170 to prevent crashing.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select: 684000 1.1670000000013 | |
tables: 684000 0.61299999999756 | |
select: 684000 1.1729999999952 | |
tables: 684000 0.64100000000326 | |
select: 684000 1.176999999996 | |
tables: 684000 0.63500000000931 | |
select: 684000 1.1710000000021 | |
tables: 684000 0.63799999999173 | |
select: 684000 1.1719999999914 | |
tables: 684000 0.63199999999779 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select: 684000 0.632 | |
tables: 684000 0.466 | |
select: 684000 0.632 | |
tables: 684000 0.47 | |
select: 684000 0.635 | |
tables: 684000 0.471 | |
select: 684000 0.635 | |
tables: 684000 0.471 | |
select: 684000 0.636 | |
tables: 684000 0.469 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Crashes! Bug? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment