Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #16935

Re: Built-in native method

Message-ID <1626770.WBuXB4FIxE@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2012-10-28 21:23 +0100
Subject Re: Built-in native method
Newsgroups comp.lang.javascript
References (4 earlier) <k6jfld$q6l$1@speranza.aioe.org> <1886339.7pA5ev5edD@PointedEars.de> <k6jqlh$nlb$1@speranza.aioe.org> <270317591.RgZlF00zI7@PointedEars.de> <k6k0n0$8eb$1@speranza.aioe.org>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


Cezary Tomczyk wrote:

> W dniu 2012-10-28 20:10, Thomas 'PointedEars' Lahn pisze:
>> Cezary Tomczyk wrote:
>>> I even extended little bit this test
>>> http://jsperf.com/typeof-equals-triple-double by comparing two different
>>> objects and IE9, Google Chrome 22.0.1229.94, Opera 12.02 for 4 tests are
>>> more or less similar, but Firefox 16.0.2 surprised me little bit:
>>>
>>> triple equals: 8167 Ops/sec
>>> double equals: 4752 Ops/sec
>>> triple equals - different objects: 90830 Ops/sec
>>> double equals - different objects: 89815 Ops/sec
>>>
>>> All of them tested on Windows 7, 64 bit.
>>>
>>> What a huge difference. Weird for me, little bit.
>>
>> 1. You are benchmarking the wrong feature there.
> 
> Ok, maybe I should do two separate tests.

You wanted to test `==' vs. `==='.  What you are actually testing there is 
`typeof ""' vs. `typeof {}'.  Keep in mind that the `typeof' operation 
*always* results in a string value.

>> 2. I do not think you need loops with jsperf.
> 
> Is there better way?

Yes, omit them.  jsperf loops by itself, and if it is any good it uses 
nested loops.

>> 3. Never trust benchmarks.
> 
> Then one of the alternative is to measure time by using new
> Date().getTime() :/

No, the reasonable alternative is to profile real code under real conditions 
if and when slow speed becomes a problem.  A V8 JavaScript profiler is 
included in the Chromium/Chrome Developer Tools; Firebug contains one for 
SpiderMonkey as well.  Premature optimization is the root of all evil. [tm]

The issue of `==' vs. `===' is not so much speed; it is the outcome of 
either operation, which can be unexpected in the former case.


PointedEars
-- 
Sometimes, what you learn is wrong. If those wrong ideas are close to the 
root of the knowledge tree you build on a particular subject, pruning the 
bad branches can sometimes cause the whole tree to collapse.
  -- Mike Duffy in cljs, <news:Xns9FB6521286DB8invalidcom@94.75.214.39>

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-19 22:07 +0200
  Re: Built-in native method JJ <jaejunks_at@_googlemail_dot._com> - 2012-10-21 06:44 +0000
    Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-21 18:46 +0200
    Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-21 19:37 +0200
      Re: Built-in native method Andreas Bergmaier <andber93@web.de> - 2012-10-22 15:47 +0200
        Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-22 18:00 +0200
          Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-24 02:17 +0100
            Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-24 22:17 +0200
              Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-25 00:32 +0200
  Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-24 02:15 +0100
    Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-24 22:35 +0200
      Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-25 00:03 +0200
        Re: Built-in native method Asen Bozhilov <asen.bozhilov@gmail.com> - 2012-10-26 03:58 -0700
          Re: Built-in native method RobG <rgqld@iinet.net.au> - 2012-10-29 16:39 -0700
        Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 15:32 +0100
          Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 17:05 +0100
            Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 18:39 +0100
              Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 20:10 +0100
                Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 20:23 +0100
                Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 21:23 +0100
                Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 22:03 +0100
        Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 15:49 +0100
          Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 17:12 +0100
            Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 17:49 +0100
              Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 18:07 +0100
                Re: Built-in native method Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-28 19:22 +0100
                Re: Built-in native method Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-28 19:53 +0100

csiph-web