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). :)

Reply via email to