Hi Tucker,
I've been working a few kinks out of the runtime, and reading the docs
on LzNode.construct(), which say:
@param Object args: A dictionary of initialization arguments that should
* be applied
* to the instance. This contains any arguments that are default arguments
* written in the class definition. Note that initial value
* expressions (`$once{...}`) and constraints (`${...}`), are in this
* list also, they can be differentiated from initial values by their
* type: `LzInitExpr` for the former, and `LzConstraintExpr` for the
* latter. If you handle the installation of any instance attributes
* in your construct method, you are responsible for dealing with
* these "binders" as well. Normally, they will be processed by
* LzNode.
So, I did a little performance testing
(trunk/test/performance/typeof-instance-of.lzx) and found a few
potential optimizations:
a) typeof func == 'function' is about 2x faster than f instanceof Function.
b) typeof seems to be much faster than instanceof. Since many arguments
are not LzInitExpr, it might be worth doing this:
typeof arg == 'object' && arg instanceof LzInitExpr;
instead of just this:
txt instanceof LzInitExpr;
Here are my numbers for swf8:
iterations = 200
empty : 6.35us ± 2.23 [5.00..10.00]/100
instanceof : 30.25us ± 2.88 [20.00..35.00]/100
typeof : 21.05us ± 2.59 [10.00..25.00]/100
typeof with instanceof : 30.00us ± 2.25 [25.00..35.00]/100
property lookup : 19.60us ± 2.43 [15.00..25.00]/100
typeof with instanceof with short circuit: 15.05us ± 0.87
[10.00..20.00]/100
typeof function : 12.90us ± 2.48 [10.00..15.00]/100
instanceof function : 26.40us ± 2.26 [25.00..30.00]/100
And for DHTML, firefox OS x:
iterations = 200
empty : 5.65us ± 1.69 [5.00..10.00]/100
instanceof : 29.90us ± 7.85 [15.00..40.00]/100
typeof : 17.40us ± 4.23 [10.00..25.00]/100
typeof with instanceof : 30.40us ± 3.94 [20.00..35.00]/100
property lookup : 15.35us ± 1.78 [10.00..20.00]/100
typeof with instanceof with short circuit: 12.75us ± 2.50 [10.00..15.00]/100
typeof function : 12.40us ± 2.51 [10.00..15.00]/100
instanceof function : 19.10us ± 2.29 [15.00..25.00]/100
Let me know what you think...
--
Regards,
Max Carlson
OpenLaszlo.org