Main Menu

That's So Random

Started by Darren Dirt, May 26, 2013, 11:09:55 AM

Previous topic - Next topic

Mr. Analog

I tried it with Chrome but I didn't even think to try it with others!

Interesting!
By Grabthar's Hammer

Darren Dirt

Also interesting: the "jsperf.com" site itself!

It's basically like a Wiki for testing JS code (esp. comparing Method1 vs Method2) and has a wizard-y interface so if your code depends on jQuery or whatever you have a place to include that or make reference to that requirement -- thus allowing for really easy re-use/cloning of your tests!
_____________________

Strive for progress. Not perfection.
_____________________

Mr. Analog

Yep, you can actually download and play with the site yourself: https://github.com/mathiasbynens/jsperf.com

And contribute to the scripts.

Pretty cool find if you ask me
By Grabthar's Hammer

Lazybones

Quote from: Darren Dirt on May 27, 2013, 01:29:43 PM
yeah Math Is Fun.


and btw from the above link ( @ jsperf.com ) did anyone else do a "test" in their web browser?

I'm curious if anyone has Firefox, I wonder if (unlike the other browsers) with FF it is indeed WAY SLOWER with Xorshift than the built-in (which might mean that either FF's Javascript engine sucks for shifts/rotates, or that its built-in random is wicked smaht.)

Not sure, I use FF full time and between releases Chrome and FF keep shifting the javascript  performance crown.

Mr. Analog

I find it interesting when browsers excel at different operations, it really brings the dev thinking out front.

Like you could have really good loop processing in one at a cost to memory vs really good stack management but high CPU... the end result is usually close but totally different ways of solving things.
By Grabthar's Hammer

Darren Dirt

#20
Quote from: Darren Dirt on May 27, 2013, 01:35:45 PM
Also interesting: the "jsperf.com" site itself!

It's basically like a Wiki for testing JS code (esp. comparing Method1 vs Method2) and has a wizard-y interface

lotsa people are using it for similar things, esp. "which method of grabbing an HTML/DOM element is fastest?
http://jsperf.com/popular#all-time



...also, lol, the devs behind jsperf.com recognize how lazy some developers might be  8)


and speaking of lazy...
Quote from: http://www.phpied.com/jsperf-bookmarklet/

These days we're so happy and spoiled with all these amazing tools around us. And yet, when you create a JSPerf test, you have to open all these browsers and run the test everywhere. Even IE. And, when on Mac, IE is usually not readily available. Plus it comes in a bunch versions - from almost-but-not-quite-forgotten IE6, all the way to IE10 The Greatest - and they have different, sometimes contradicting, performance characterics.

To the rescue: The bookmarklet WPT! WebPagetest has: a/ ability to run in a bunch of browsers and b/ an API.

_____________________

Strive for progress. Not perfection.
_____________________

Thorin

#21
Here's an interesting one: http://jsperf.com/caching-array-length/4#run

It's running through a for loop.  In both Chrome 27 and IE 9, the first option (creating length variable inside the for statement and comparing against it instead of the array's length) is the fastest.  But what's really interesting is Chrome 27 can do this over 4mil times per second, while IE 9 can do this a little over 0.5mil per second.  Chrome is 8 times faster than IE at looping?  WOW!

edit: just tried in Firefox 15, it could do 7mil per second!
Prayin' for a 20!

gcc thorin.c -pedantic -o Thorin
compile successful

Lazybones

#22
Firefox 15? If you are going to compare to chrome you should probably get your self into the current release cycle..

I ran the tests on my machine with both browsers and ya the results are interesing, but as a whole FF was king.

http://jsperf.com/xorshift
Chrome 27
Xor 135,788,543 ?6.16% fastest
Math.rand 120,637,416 ?14.02% 17% slower

FF 21
Xor 5,537,393 ?2.54%99% slower (A LOT slower than Chrome)
Math.rand 602,939,076 ?38.85%fastest (crazy fast compared to Chrome)


http://jsperf.com/caching-array-length/4
Chrome
29,093,431 ?12.48% fastest
22,983,414 ?24.46% fastest
20,272,404 ?15.13% 32% slower
24,187,360 ?21.35% fastest
9,902,878 ?15.43% 67% slower
4,801,304 ?4.32% 82% slower

FF (all values best Chrome)
35,768,070 ?2.11%fastest
33,856,985 ?1.24%5% slower
27,761,298 ?5.24%25% slower
33,614,277 ?5.13%fastest
24,514,926 ?1.48%31% slower
11,179,207 ?0.71%68% slower

FF is 2.5x faster at while loops than Chrome.