mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
8ea4b63878
git-subtree-dir: src/lib/middleclass git-subtree-split: 27a64f107e61532006030a6168e4fe6a71eee9a2
44 lines
608 B
Lua
44 lines
608 B
Lua
local class = require 'middleclass'
|
|
|
|
time = require 'performance/time'
|
|
|
|
time('class creation', function()
|
|
local A = class('A')
|
|
end)
|
|
|
|
local A = class('A')
|
|
|
|
time('instance creation', function()
|
|
local a = A:new()
|
|
end)
|
|
|
|
function A:foo()
|
|
return 1
|
|
end
|
|
|
|
local a = A:new()
|
|
|
|
time('instance method invocation', function()
|
|
a:foo()
|
|
end)
|
|
|
|
local B = class('B', A)
|
|
|
|
local b = B:new()
|
|
|
|
time('inherited method invocation', function()
|
|
b:foo()
|
|
end)
|
|
|
|
function A.static:bar()
|
|
return 2
|
|
end
|
|
|
|
time('class method invocation', function()
|
|
A:bar()
|
|
end)
|
|
|
|
time('inherited class method invocation', function()
|
|
B:bar()
|
|
end)
|