News for hackers. Stuff that matters.
Re:There are 25 votes for an inaccurate SO answer. Help me p... by slapshot on Thursday February 03, 2011 @12:19PM (#2175542)
Obligatory, especially when all of HN is being called in to correct it: http://xkcd.com/386/
Re:There are 25 votes for an inaccurate SO answer. Help me p... by yahelc on Thursday February 03, 2011 @11:38AM (#2175369)
The SO thread in question is this one: http://stackoverflow.com/q/4837876/172322

The accepted answer has correct options, but its inaccurately suggesting that the Sizzle selectors are faster. I setup this JSPerf test to prove that Sizzle is least efficient, and that in fact the OP's version seems to be THE fastest across all the browsers. The more data points I can gather, the more effectively I'll be able to rebut that the conventional wisdom here is wrong.

Re:There are 25 votes for an inaccurate SO answer. Help me p... by timrobinson on Thursday February 03, 2011 @12:00PM (#2175463)
The answer just states that "it has been hypothesized", so technically it's correct. It doesn't claim whether this is true; the answerer needs "a reliable cross-browser, multi-document benchmark" in order to do that.

Besides, if I worried about every wrong-yet-accepted answer on StackOverflow, I'd be quite worried by now.

Re:There are 25 votes for an inaccurate SO answer. Help me p... by yahelc on Thursday February 03, 2011 @12:10PM (#2175507)
Yes, I guess I could say "it has been hypothesized that the world was created in 6 days 5,000 years ago", and I wouldn't be wrong :)

Inaccurate-yet-accepted with 0-2 upvotes: Not damaging.

Inaccurate-yet-accepted with 25 upvotes: Has the potential to widely perpetuate false beliefs.

Re:There are 25 votes for an inaccurate SO answer. Help me p... by mdg on Thursday February 03, 2011 @11:54AM (#2175431)
That person had "should" italicized. Also, the question is asking what the most elegant solution would be, not the most fast.
Re:There are 25 votes for an inaccurate SO answer. Help me p... by yahelc on Thursday February 03, 2011 @11:56AM (#2175443)
Totally. I don't think the Accepted Answer should be downvoted (since its rigorous and not intentionally misleading), but merely that there should be data to back-up the claims (and the 'Accepted Answer' he links to doesn't provide supporting evidence). This is how bad information is spread.

Also, I'm arguing that performance "should" be trumped by elegance if the performance differences are so significant.

Re:There are 25 votes for an inaccurate SO answer. Help me p... by piers on Thursday February 03, 2011 @12:26PM (#2175573)
Slightly OT, but is it really that difficult to tell the difference between Windows Server 2008R2 and Windows 7? The linked page doesn't seem to be able to tell the difference between the two.
Re:There are 25 votes for an inaccurate SO answer. Help me p... by mathias on Thursday February 03, 2011 @02:30PM (#2176351)
Hey, I’m the guy who made the jsPerf website.

The product token for Windows Server 2008R2 and Windows 7 is the same (6.1) so there’s technically no way to tell the difference. jsPerf is supposed to show you it could be both, not one of them. Is this bugged?

Re:There are 25 votes for an inaccurate SO answer. Help me p... by yahelc on Thursday February 03, 2011 @03:29PM (#2176657)
Much love to JSPerf.

OT, but, is there any way to embed the results dynamically?

Re:There are 25 votes for an inaccurate SO answer. Help me p... by jdd on Thursday February 03, 2011 @04:20PM (#2176881)
There is, but it's not easily to digest at the moment. You need the Browserscope key + Google's visualization library. You can reference https://github.com/mathiasbynens/benchmark.js/blob/master/pl...
Re:There are 25 votes for an inaccurate SO answer. Help me p... by piers on Thursday February 03, 2011 @03:19PM (#2176611)
I'm not having a dig at the site. And I didn't know that about the product token.

Could you not do something with the user agent or do you get that already?

Re:There are 25 votes for an inaccurate SO answer. Help me p... by jdd on Thursday February 03, 2011 @04:10PM (#2176830)
Benchmark.js (http://benchmarkjs.com), which jsPerf uses, does checks the UA string as well as feature tests for various environments. You can check the code out at https://github.com/mathiasbynens/benchmark.js/blob/master/be....

Here is a MSDN post that examines some of the platform tokens http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx

Re:There are 25 votes for an inaccurate SO answer. Help me p... by lhorie on Thursday February 03, 2011 @12:55PM (#2175752)
Am I the only one wondering why you'd use jQuery to begin with if you actually needed these sort of micro-optimizations?

Regardless, there's an edit with a correction now.

Re:There are 25 votes for an inaccurate SO answer. Help me p... by michaelcampbell on Thursday February 03, 2011 @01:50PM (#2176095)
What does "81% slower" mean? 19% as fast?
Re:There are 25 votes for an inaccurate SO answer. Help me p... by jdd on Thursday February 03, 2011 @04:36PM (#2176979)
It's something like say your slow value was 25 ops/sec and your fast value was 100 ops/sec, then do (1 - 25 / 100) = 0.75. So as a percent 25 ops/sec is 75% slower than 100 ops/sec.