Skip to content

Instantly share code, notes, and snippets.

@Nymphium
Created February 5, 2020 07:16
Show Gist options
  • Save Nymphium/44a583f914e5fc863c0f72bc3848415b to your computer and use it in GitHub Desktop.
Save Nymphium/44a583f914e5fc863c0f72bc3848415b to your computer and use it in GitHub Desktop.
function() return error() endlocal socket = require('socket')
local gettime = socket.gettime
local TIMES = 1000000
local t1 = gettime()
for _ = 1, TIMES do
pcall(error)
end
local t2 = gettime()
local t3 = gettime()
for _ = 1, TIMES do
pcall(function() return 3 / 1 end)
end
local t4 = gettime()
local t5 = gettime()
for _ = 1, TIMES do
pcall(function() return 3 / 0 end)
end
local t6 = gettime()
print(t2 - t1, t4 - t3, t6 - t5)
@Nymphium
Copy link
Author

Nymphium commented Feb 5, 2020

$ eval $(luarocks path --lua-version 5.1)
$ luajit test.lua
1.3156471252441 0.037020921707153       0.037245035171509
$ eval $(luarocks path --lua-version 5.3)
$ lua test.lua
0.14710402488708        0.056612968444824       0.062648057937622

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment