|
|
|
|
|
by Eli_P
2363 days ago
|
|
I found it interesting how Chrome and FF handle differently cpu-heavy code like this: arr = new ArrayBuffer(4)
arrInt = new Uint32Array(arr)
t0 = performance.now(); for (; arrInt[0] <= 1000000000; ++arrInt[0]) {} ;
performance.now() - t0
On Windows it takes 2.5 secs even on old chrome versions, while it never finishes on the latest FF. The latter's call stack says firefox.exe!TargetNtUnmapViewOfSection(), xul.dll!get_stored_pointer. I wonder if that happens on other platforms?Update - on my Android: Chrome: 7.5 secs, forever on FF. Weird. If I say a var is typed it should work faster. |
|
I just tried running it in a web page, with the last line replaced by `console.log(performance.now() - t0);` and on my hardware it finishes in ~1.5 seconds in Firefox and ~2 seconds in Chrome.
Similar if I run it in a devtools console like so:
and hence avoid the undeclared global variable accesses. If I run the original code in the devtools console, it is in fact quite slow in Firefox, because global variable access is slower in the devtools console there. So each get of `arrInt` takes a quite long time. That's https://bugzilla.mozilla.org/show_bug.cgi?id=793345 and I suspect that's what you're running into here.The main moral is to not do performance testing in the console, because it's a _very_ different execution environment from actual web pages.