[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Method call Performance (Was Re: OOP in daydream...)
- From: "Steve Donovan" <sjdonova@...>
- Date: Wed, 19 Jan 2005 13:40:33 +0200
It's interesting to compare various ways of implementing
inheritance in lua.
Here are some numbers:
- global function call 1.0
- copying methods into class 1.5
- custom __index function 5.0 (!)
- nested metatables 2.0
For the inheritance tests, a method of the base class
was called by an object of a derived class, twice
In summary; method dispatch isn't too bad, unless
you use a custom function to look up symbols.
Generally keeping 'fat' classes (that include all
methods) is better; this will not depend on
the depth of inheritance.
Of course, your mileage may vary...