$ src/luajit test1.lua
test3/lua 0.000812
test2/lua 0.047739
$ src/luajit test2.lua
test2/lua 0.050938
test3/lua 0.000856
Created
January 5, 2016 12:34
-
-
Save mraleph/7a75daee13ad783d8f78 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require "vector3" | |
collectgarbage() | |
test3() | |
collectgarbage() | |
test2() |
This file contains hidden or 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
require "vector3" | |
collectgarbage() | |
test2() | |
collectgarbage() | |
test3() |
This file contains hidden or 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
local Vector3 = { __typename = 'Vector3' } | |
do | |
local setmetatable = setmetatable | |
local I = { __typename='Vector3' } | |
Vector3.__call = function(t, x, y, z) | |
return setmetatable({x or 0, y or 0, z or 0}, I) | |
end | |
setmetatable(Vector3, Vector3) | |
end | |
function test2() | |
local start = os.clock() | |
for i = 1,200000 do | |
local up = Vector3(0,1,0) | |
tostring(up) | |
end | |
print("test2/lua " .. (os.clock() - start)); | |
end | |
function test3() | |
local start = os.clock() | |
for i = 1, 2000000 do | |
Vector3(i, i, i) | |
end | |
print("test3/lua " .. (os.clock() - start)); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment