Using Debian 8, the latest version of Chrome (Chromium) available from the standard repositories is 57. I've been doing some very simple speed tests and obtaining strange results.
When I run the following one-liner in the Console, it completes in about 1 second:
var a = 0;for (var i = 0; i < 10000000; i++) {a = Math.sqrt(33 * Math.random());}console.log(a);
But if I create a button with an onclick
handler containing the same code, execution takes more than 15 seconds:
<button onclick="var a = 0;for (var i = 0; i < 10000000; i++) {a = Math.sqrt(33 * Math.random());}console.log(a);">Test</button>
Can anyone shed some light on why this is?
EDIT:
If I separate the code out into a function in a script tag, and reference that function in the button onclick
handler, it works as fast as in the Console, a little faster actually.