W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2015

Re: Why is querySelector much slower?

From: Glen Huang <curvedmark@gmail.com>
Date: Wed, 29 Apr 2015 12:23:07 +0800
Cc: public-webapps <public-webapps@w3.org>
Message-Id: <108BDDE4-3F3A-4BA4-8A7C-7C966021E3F3@gmail.com>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
Woooow, this is pure gold. Thank you so much for such thorough explanation, any even took the trouble to actually implement optimizations to make sure the numbers are right. I'm so grateful for the work you put into this just to answer my question. How do I accept your answer here? ;)

> So what you're seeing is that the benchmark claims the operation is performed in 1-2 clock cycles

I never thought about relating ops/sec numbers to clock cycles. Thanks for the tip.

> So what this getElementById benchmark measures is how fast a loop counter can be decremented from some starting value to 0.

This makes so much sense now.

> because of the proxy machinery involved on the JS engine side

Do you mean the cost introduced by passing a C++ object into ecmascript world?

> In this case, those all seem to have about the same cost;

I now see why querySelector has some extract work to do.

> But for real-life testcases algorithmic complexity can often be much more important.

Yes. But I suddenly find microbenchmarks to be a wonderful conversation starter. ;)

Thanks again for all the explanations, I'm motivated by them to actually dig into the engine source code to discover things myself next time (probably not easy, but should be rewarding). :)
Received on Wednesday, 29 April 2015 04:23:41 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:31 UTC