>
> But your benchmark still isn't balanced. For example, fn [1b] is using
> more pure JS/DOM functions and is implemented on Array, while fn [4]
> is using Moo overhead and is implemented on Element.
>
Really? [4] used className, so i wanted to see how big the change was when
using className in [1a] too (and for pure JS i think i should replace the
".each", but this wont make a big difference i think). Actually using pure
JS for "contains" makes [4] 30x times faster than before, while hasClass
does the same:
hasClass: function(className){
return this.className.contains(className, ' ');
},
contains: function(item, from){
return this.indexOf(item, from) != -1;
},
Anyway its a question of milliseconds and i don't think it will ever matter
in productive enviroment. So what is the best method to programm such a type
of functions? The moo way or pureJS way?
Moo code is more portable&durable but in some situations it could be a
performance killer. In this case RegExp+moo's get/set is still faster then
all other methods using moo code whenever its possible, mainly because it
needs less of it. I think it will always be a compromise between speed and
the ease&usefullness of moo, unless somebody writes a moo2pureJS compiler.
(Would be a nice experiment, though).
Well, enough benchmarking for today, i hope i didn't annoyed anybody by
blowing up this thread with all this stuff.
Yann
On Wed, Feb 24, 2010 at 00:52, Sanford Whiteman <[email protected]
> wrote:
> But your benchmark still isn't balanced. For example, fn [1b] is using
> more pure JS/DOM functions and is implemented on Array, while fn [4]
> is using Moo overhead and is implemented on Element.
>
> The most apt competitor to your className.RegExp is className.indexOf.
> I adjusted fn [4] accordingly. I think you'll see that [4] wins out at
> n=10000, 1000, 100 and is about the same at n=10 (I don't think n=10
> is appropriate to test, since there is no "smoothing" effect in a
> benchmark that small).
>
> http://mootools.net/shell/bmfGu/3/
>
> -- S.
>
>
>
>
>