in reply to Re^6: webperl: fetching data over the web
in thread webperl: fetching data over the web

> There is obviously something very inefficient going on with the <textarea>, I'll take a guess that it's this line: ta.value = ta.value + str;.

I've testet it in pure JS inside your webperl/plack environment.

Adding the whole of emperl.js to a textarea works without problem in my FF.

But appending 3000 lines in a loop creates an "out of memory" exception (adding only half the lines still works)

So buffering output (think $| ) might be a solution.

I'm expecting your ta.scrollTop = ta.scrollHeight; to mean even more trouble. *

<!doctype html> <html lang="en-us"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" +> <title>WebPerl &lt;script&gt; Demos</title> <script type="text/javascript"> function xfetch(url) { var req = new XMLHttpRequest(); req.open('GET', url , false); req.send(null); if(req.status == 200) { return req.responseText; } else { return ""; } } </script> </head> <body> <textarea id="test" cols=100 rows=80> </textarea> <script> var data = xfetch('http://localhost:5000/emperl.js'); var ta = document.getElementById("test"); // --- add one big chunk //ta.value += data; // --- add line by line var lines = data.split(/;/); ta.value += "lines.length: " + lines.length + "\n\n\n"; if (true) for (var i=0; i<lines.length; i++) ta.value+=lines[i]+";"; </script> </body> </html>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

*) indeed scrolling makes the whole unresponsive with much smaller line-counts already.

Replies are listed 'Best First'.
Re^8: webperl: fetching data over the web
by haukex (Archbishop) on Nov 11, 2018 at 08:53 UTC

    What's even worse is that Emscripten may decide to provide the STDOUT stream on a character-by-character basis! (I don't think there's a clear spec on its behavior, i.e. whether it's characters or blocks.)