From: Garrett Smith on
Thomas 'PointedEars' Lahn wrote:
> Garrett Smith wrote:
>
>> Jorge wrote:
>>> On Jan 5, 7:58 pm, Garrett Smith <dhtmlkitc...(a)gmail.com> wrote:
>>>> Jorge wrote:
>>>>> On Jan 5, 9:23 am, Jorge <jo...(a)jorgechamorro.com> wrote:
>>>>>> On Jan 5, 8:07 am, Garrett Smith <dhtmlkitc...(a)gmail.com> wrote:
>>>>>>> (...)
[...]

>> The reason for using that weird property name is have a fair comparison
>> on a level field with speed test for the namespace function. The same
>> name property assignment was copied from the other tests.
>
> The comparison is _not_ fair because `window' is not a (safe) reference to
> the global object.
>

The performance times resulting from using value from `window` or `
(function(){return this;})();` don't vary.

> I had only cancelled my follow-up (that you had replied to anyway two hours
> later) because I observed, to my surprise, that `this' referring to the
> global object was (about 50%) slower than `global' where `global' was a
> property of the global object (even if it stored a reference to the global
> object) in Firebug (to which might the difference might be attributed; I
> would set up a Firebug-unrelated test case then).
>

just use:-

var p = (function(){return this;})();

(function(){
var p = (function(){return this;})(); // window.
var d = new Date;
for(var i = 0; i < 10000; i++)
p["d" + ".b" + i + ".c.d"] = i;
return new Date-d;
}())

Make sure to reload the page after running each test. Subsequently
running the test will be faster.

Also, you can type the code into bookmarklet to run in Firefox.

1) copy code above
2) javascript:alert( /*paste*/ )
3) Hit Enter.

Again, the performance times resulting from using value from `window` or
` (function(){return this;})();` don't vary.

> The rest of my points still apply for other cases than this: What matters
> here is _not_ whether the object-referring property is one of the global
> object but in how deep an execution context it is used (i.e., the length of
> the effective scope chain) and how many property accesses are necessary to
> retrieve the reference (i.e., the number of components -- and maybe the
> length of the expression, too, considering how hash tables work -- in the
> property accessor expression).
>
>

For property assignment, it should be a [[Put]] on that object. For
window, well, window has an extended prototype chain that includes a
[[GlobalScopePolluter]], and so it may be referencing properties on that.

Larger number of properties on the object might also slow performance.
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Garrett Smith on
Thomas 'PointedEars' Lahn wrote:
> kangax wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> kangax wrote:
>>> There is *nothing* in the Specification that says that Function
>>> instances are not [[Construct]]able by default. In fact, function
>>> instances/objects do have by default an internal [[Construct]]
>>> property. (13.2)
>> Aren't we talking about built-in functions? What do Function instances
>> have to do with this?
>
> If you had cared to read the definitions I quoted ...
>
>>> However, in any case the statement "None of the built in functions may
>>> be used as a constructor." is not only incomplete; it is obviously
>>> _wrong_. As the statement is an existential negation, to prove it
>>> wrong I need only one counter-example:
>>>
>>> var o = new Object();
>> How is this a proof?
>
> `Object' is a built-in function.
>

What do you think the Object Constructor is? Why do you think the
specification calls it "The Object Constructor"?
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Jorge on
On Jan 6, 12:16 am, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
> (...) What matters
> here is _not_ whether the object-referring property is one of the global
> object but in how deep an execution context it is used (i.e., the length of
> the effective scope chain) and how many property accesses are necessary to
> retrieve the reference (i.e., the number of components -- and maybe the
> length of the expression, too, considering how hash tables work -- in the
> property accessor expression).

That's what one would logically deduce, but the tests show that
there's something else (in addition). He is aliasing the target object
in a local var, and even so there's a slight difference in speed: when
the aliased object is either the window object or the global object
access times are longer than when the object is a {}.

http://jorgechamorro.com/cljs/090/

And disabling FireBug does not seem to have an effect on the results.
--
Jorge.
From: Garrett Smith on
Jorge wrote:
> On Jan 5, 2:55 am, Garrett Smith <dhtmlkitc...(a)gmail.com> wrote:
>> Apple lies to the consumers about the technology.
>
> Could you please elaborate ?
>

First mobile web browser? Apple? No, how about windows mobile or maybe
Nokia S60.

>> Makes a web-incompatible browser
>
> Which is ... ?
>

Safari on iPhone, of course. Doesn't support even basic CSS overflow;
Doesn't support mousemove event.

>> patents the incompatibility
>
> You probably mean the touch/gestures iPhone JS API ?
>

Yes.

>> prevents other
>> browser competition on iPhone.
>
> Here's a thought: design from scratch, build and try to sell your own
> "smartphone". Then allow your competitors to put their software in
> (Flash comes to my mind) so that you risk loosing control over your
> own invention. Bright idea, yeah.
>

I could care less about Flash. How about not monopolize the OS by
disallowing Fennec, which is free.

>> The word "advertisement" comes from latin. The root word "advertise"
>> means "turn toward".
>
> And the saying think before you talk means exactly what it says.
Did you have a point or?

> --
> Jorge.


--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Jorge on
On Jan 6, 1:27 am, Garrett Smith <dhtmlkitc...(a)gmail.com> wrote:
> Jorge wrote:
> > On Jan 5, 2:55 am, Garrett Smith <dhtmlkitc...(a)gmail.com> wrote:
> >> Apple lies to the consumers about the technology.
>
> > Could you please elaborate ?
>
> First mobile web browser? Apple? No, how about windows mobile or maybe
> Nokia S60.

Mobile IE ? Are you serious ? That's the worst IE ever ! even worse
than desktop IE ! (wait, is that possible ?)

And S60 === a badly broken, buggy fork of webkit. Still, much better
than any mobile IE.

The truth is that the first serious, decent browser ever on a
smartphone has been mobile Safari. No matter what you say or how much
you hate Apple and everything Apple. That's not my personal opinion,
it's a fact, it's history.

> >> Makes a web-incompatible browser
>
> > Which is ... ?
>
> Safari on iPhone, of course. Doesn't support even basic CSS overflow;

Assuming you mean e.g. overflow-x:hidden; , which version does not
support that ?

> Doesn't support mousemove event.

Does not need to as there's no mouse in the iPhone :-)

> >> patents the incompatibility
>
> > You probably mean the touch/gestures iPhone JS API ?
>
> Yes.

They are in their own right. And they have *not* said a word (yet)
about the licensing fees (if any). It could be licensed for free (and
eventually it could even become an w3 standard, then)
*but*only*if*Apple*wanted*... :-)

> >> prevents other
> >> browser competition on iPhone.
>
> > Here's a thought: design from scratch, build and try to sell your own
> > "smartphone". Then allow your competitors to put their software in
> > (Flash comes to my mind) so that you risk loosing control over your
> > own invention. Bright idea, yeah.
>
> I could care less  about Flash. How about not monopolize the OS by
> disallowing Fennec, which is free.

Fennec ? What's Fennec ?

> >> The word "advertisement" comes from latin. The root word "advertise"
> >> means "turn toward".
>
> > And the saying think before you talk means exactly what it says.
>
> Did you have a point or?
Yes, that your comments really make me sick. grrr.
--
Jorge.