func5000 - how far does your UA get?
Wednesday, 28. November 2007, 19:01:47
func5000.htm
I'd really like to know if there is a hard-coded limitation or if it depends on system speed and memory, for example. Discussion is open in the comments
the web is a hack
Wednesday, 28. November 2007, 19:01:47
what I take for granted..IE allows a semicolon between if block and else![]()
The thing is that just about any value *except* Object will keep ...
IE's DOM is terribly incomplete and flawed. Their DOM to javascr ...
OMG, so now "works in Safari != works in Chrome"? Poor web devel ...
From the forum:Safari - HTMLDivElementConstructor FF & Chrome - ...
Well, HTMLAnchorElement.prototype.constructor == HTMLAnchorEleme ...
Haven't even bothered testing because I assume Google wouldn't p ...
With firefox I get "- died when trying to call function 1000, error was "too much recursion""
By Ramunas, # 28. November 2007, 19:05:25
By scottj, # 28. November 2007, 19:49:22
"function 4998 running" on Opera 9.50.9665.0
IE 6.0.2900.2180 reports '- died when trying to call function 1124, error was "Out of stack space"'
Fx 2.0.0.10 reports: '- died when trying to call function 1000, error was "too much recursion"'
Safari 3.0.3 reports: '- died when trying to call function 98, error was "Maximum call stack size exceeded."'
PS: May I suggest uploading it as test.html.gz ?
By dantesoft, # 28. November 2007, 20:09:40
By Ramunas, # 28. November 2007, 20:10:31
By danigoldman, # 28. November 2007, 20:27:23
data:text/html,<script>%20var%20o;%20window.onload%20=%20function()%20{%20o%20=%20document.getElementById("out");%20recur(1);%20};%20function%20recur(n)%20{%20o.textContent%20=%20n;%20recur(n%20+%201);%20}%20</script>%20
Basically the depth is unlimited for all practical purposes, unless you're writing in continuation-passing style or you're using recursion instead of proper, unambiguous-performance looping constructs for iteration. (Can you guess what I think of languages which force iteration to be written to appear at the surface as stack-exhausting recursion? For any simple algorithm, the code to implement it shouldn't be required to look like it performs worse than it actually does.)
By Waldo, # 28. November 2007, 20:32:17
Opera 9.50.9665.0 Iteration depth: 9998
FX 2.0.0.10 Iteration depth: 1000
Safari 3.0.3 Iteration depth: 99
By putting a "window.status = n" in front of "recur(n + 1)", it's possible to see the result in IE6, too: I get an iteration depth of 1124
By dantesoft, # 28. November 2007, 20:40:43
Error: "Maximum call stack size exceeded."
But the smallest result I could get was under Adobe Air(uses WebKit, well, at least a very old version from mid 06 or so), after 98 calls it stopped.
By The Leaf, # 28. November 2007, 21:17:56
By ct13, # 28. November 2007, 21:51:56
- died when trying to call function 498, error was "Maximum call stack size exceeded."
Opera 9.24 Build 3707 on Mac OS X 10.5.1:
function 2498 running
By dors, # 28. November 2007, 22:06:03
System: Windows XP
Java: Sun Java Runtime Environment version 1.6
TEST RESULTS, sorted by time
Opera 9.50 9665
Firefox 2.0.0.9
Netskape Navigator 9.0b1
{...full code displayed and... } /* this is function 4835 */Safari 3.0.3
MSIE 5.01
MSIE 5.5
MSIE 6
MSIE 7
By melnichuck, # 28. November 2007, 22:12:48
On a slightly similar note, try the TC in this bug to watch Safari and IE6 die, Opera and IE7 throw an exception and FF handle it just fine.
By burnout426, # 28. November 2007, 22:25:44
Firefox 3.0b2pre
By FataL, # 28. November 2007, 22:32:45
Minefield/3.0b2pre -
Opera 9.24.8816 -
IE 7 -
Windows XP/SP2 - 256MB Ram
By AyushJ, # 28. November 2007, 22:42:54
Opera 9.5 alpha: function 4998 running
Firefox 3 beta 1: completed all 5000.
Epiphany (running Gecko 1.8.1.9, equiv. to Firefox 2.0.0.9): stopped at 1000 with "too much recursion"
Konqueror 3.5.8: - died when trying to call function 998, error was "Exceeded maximum function call depth."
On Windows XP (768 MB RAM, 2.93 GHz Celeron):
Safari 3.0.4: - died when trying to call function 498, error was "Maximum call stack size exceeded"
IE7: - died when trying to call function 2550, error was "Out of memory"
No change on IE7 when I closed some more apps to free up memory.
By Kelson, # 28. November 2007, 23:08:35
kestrel (b9624): function 4998 running
merlin (9.24): function 2501 running
op 7.52 (b3808): function 1672 running
ie6: - died when trying to call function 1124, error was "Out of stack space"
saf 3.0.4b: - died when trying to call function 498, error was "Maximum call stack size exceeded."
ff2.0.0.10: - died when trying to call function 1000, error was "too much recursion"
ff3.0b1: function 5000 running - FINISHED! 5000 function calls took 264ms
Using waldo's test:
kestrel (b9624): Iteration depth: 9998
saf 3.0.4b: Iteration depth: 499
ff2.0.0.10: Iteration depth: 1000
ff3.0b1: Iteration depth: 228816
By liorean, # 29. November 2007, 02:33:54
-First message was:
"FAILED (seems stresstest script did not even parse.. though please wait a few seconds..)"
-Then..
"function 4998 running"
..I hope we can reach the 5000 mark soon! Looks like we have some catching up to do (at least a little bit...ff3).
Firefox 2.0.0.10 (x64)
'- died when trying to call function 1000, error was "too much recursion"'
Firefox 3 (Win32)
"function 5000 running - FINISHED! 5000 function calls took 313ms"
IE7 (Win32)
' - died when trying to call function 2550, error was "Out of memory"'
It looks like most are hard coded I guess. Opera 9.2x seems to be getting a few different results, while 9.5x is getting constants like IE and FF did.
By kyleabaker, # 29. November 2007, 09:00:41
Originally posted by Opera 9.50.9656:
Originally posted by Firefox 3 Beta 1:
Originally posted by IE7:
WinXP Pro SP2 384MB 2.2 GHz
Firefox's average time was around 550ms after refreshing.
just submitted http://browsershots.org/http://files.myopera.com/hallvors/blog/func5000.htm
MS IE 6.0 on Windows 2000 crashed (oops... I didn't mean too!); died at 1124
Safari 3.0.3 for Windows 2000 died at 98, call stack size exceeded.
Firefox 2.0.0.9 for Windows 2000 died at 1000 - too much recursion
Opera 9.24 for Windows XP - function 2504 running
By IceArdor, # 29. November 2007, 09:35:33
firefox 3b1 (amd x2 (s939) @2100mhz, 2gb ddr @230mhz 2-2-2-5 1T)
others failed, seems to me clearly, that FF 3 does this test the best
By opera950beta2, # 29. November 2007, 10:32:31
By HeroreV, # 29. November 2007, 14:59:48
By raphman, # 29. November 2007, 15:19:33
- Opera 9.24: "function 2500 running"
- opera-9.50-20071109.6-shared-qt.i386-1662: "function 4998 running"
- Firefox 2.0.0.10: "- died when trying to call function 1000, error was "too much recursion""
- Wine-emulated IE6: "- died when trying to call function 500, error was "Not enough memory.""
By graste, # 29. November 2007, 16:04:48
Didn't test other browsers.
Comment: This doesn't test recursion, though. This just tests how many different functions can be nested. A situation where you only use function recursion instead of loops shouldn't have exactly the same constraints as nested individual functions, imho. I'm just very bad at functional recursion so I can't really test it...
Also it would theoretically be possible to optimize for functions with identical function body (which you are using a ton of). So... er... maybe you should create them with Function(), give them some different number to crunch and see what happens? ;D
By _Grey_, # 29. November 2007, 20:25:36
function 5000 running - FINISHED! 5000 function calls took 568ms
By rsemil, # 30. November 2007, 03:42:54
Also, the function bodies are not quite identical - they contain different numbers in the string that is passed to the DOM and in the name of the next function called. I don't write JS compilers myself but I'd be quite impressed if anyone could optimise for similar functions with such differences.
The various test results seem to show that most browsers have hard-coded call depth limits. The grand exception is Firefox 3, which calculates the limit dynamically. I wonder if it can give JS that much resources and still avoid a rogue script slowing down or freezing your entire system.
By hallvors, # 4. December 2007, 00:38:10
By _Grey_, # 4. December 2007, 20:09:20
By vokca_charcoal, # 13. December 2007, 12:20:40
Firefox pops up a dialog to the user when scripts run for too long, asking if the user wants to stop the script or let it continue. But if a script wants to slow down or freeze a browser, there are much easier ways of doing it. In every browser I've ever tried, freezing the browser up indefinitely was very easy (when purposely trying to do it). I would be very impressed if Opera was the first one to put serious effort into overcoming this.
By HeroreV, # 17. December 2007, 02:51:40
while(true);
and observe how the UI stays fairly responsive. Because of this we have not implemented the "slow script" warning dialog found in Firefox and (I believe) also in IE. I'm not saying that you can't make Opera's UI freeze with JS tricks but I do think you have to work a bit harder..
By hallvors, # 17. December 2007, 16:47:27
function 4998 running
No changes even after 9.5 final.
By kyleabaker, # 20. June 2008, 23:36:35