Re: Create a class without external libraries
Posted: Sun Feb 14, 2016 1:09 am
So I built a quick benchmark. Creating 200 tiny instances with classes built using closures with and without "self" in the closure and with metatables.
Gist: https://gist.github.com/S0lll0s/ac8eaf50d2124016242e
Results:
Gist: https://gist.github.com/S0lll0s/ac8eaf50d2124016242e
Results:
Code: Select all
$ luajit test.lua
testing the metatable-way
memory before: 30.0322265625
memory difference: 29.1962890625
---
testing the closure-way
memory before: 33.984375
memory difference: 48.9716796875
---
testing the closure-self-way
memory before: 34.69140625
memory difference: 42.73046875