X
Tap here to go to the mobile version of the site.

Support Forum

parseInt() in Firefox significantly slower than Chrome's

Posted

Hello,

I have been doing some testing and have found the parseInt() javascript function is significantly slower in Firefox in comparison to Chrome. This is an issue as I am for looping strings and using this function to convert them to integers. In Chrome, it performs well, however in Firefox the page freezes for several seconds.

Firefox: 0.0649999999998272ms Chrome: 0.005000000004656613ms

JS Fiddle: https://jsfiddle.net/2d1pjLu5/

Cheers, Jesse

Hello, I have been doing some testing and have found the parseInt() javascript function is significantly slower in Firefox in comparison to Chrome. This is an issue as I am for looping strings and using this function to convert them to integers. In Chrome, it performs well, however in Firefox the page freezes for several seconds. Firefox: 0.0649999999998272ms Chrome: 0.005000000004656613ms JS Fiddle: https://jsfiddle.net/2d1pjLu5/ Cheers, Jesse

Additional System Details

Application

  • User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36

More Information

jscher2000
  • Top 10 Contributor
7671 solutions 62472 answers

Helpful Reply

Hi Jesse, this topic might be more appropriate for another forum:

https://discourse.mozilla.org/c/firefox-development

But out of curiosity... I modified the last line of the script so that timings accumulate and you can compare multiple runs:

https://jsfiddle.net/2d1pjLu5/1/

When I click Test 10 times, Firefox 57 gives me two initial outliers before it settles down (range of 0.010 to 0.055) (I didn't have an issue with the page freezing):

Took 0.05500000000029104ms Took 0.03999999999996362ms Took 0.015000000000327418ms Took 0.020000000000436557ms Took 0.014999999999417923ms Took 0.010000000000218279ms Took 0.010000000000218279ms Took 0.014999999999417923ms Took 0.015000000001236913ms Took 0.014999999999417923ms

Chrome 63 had a tighter range (0.010 to 0.025):

Took 0.020000000000436557ms Took 0.010000000000218279ms Took 0.014999999999417923ms Took 0.015000000000327418ms Took 0.019999999998617568ms Took 0.02500000000145519ms Took 0.024999999999636202ms Took 0.020000000000436557ms Took 0.019999999998617568ms Took 0.020000000000436557ms

I have to wonder whether the method of measurement might also be a factor, and how background processes in the browser come into play.

Of course, each subsequent set of 10 runs is different...

Hi Jesse, this topic might be more appropriate for another forum: https://discourse.mozilla.org/c/firefox-development But out of curiosity... I modified the last line of the script so that timings accumulate and you can compare multiple runs: https://jsfiddle.net/2d1pjLu5/1/ When I click Test 10 times, Firefox 57 gives me two initial outliers before it settles down (range of 0.010 to 0.055) (I didn't have an issue with the page freezing): Took 0.'''055'''00000000029104ms Took 0.'''039'''99999999996362ms Took 0.015000000000327418ms Took 0.020000000000436557ms Took 0.014999999999417923ms Took 0.010000000000218279ms Took 0.010000000000218279ms Took 0.014999999999417923ms Took 0.015000000001236913ms Took 0.014999999999417923ms Chrome 63 had a tighter range (0.010 to 0.025): Took 0.020000000000436557ms Took 0.010000000000218279ms Took 0.014999999999417923ms Took 0.015000000000327418ms Took 0.019999999998617568ms Took 0.'''025'''00000000145519ms Took 0.'''024'''999999999636202ms Took 0.020000000000436557ms Took 0.019999999998617568ms Took 0.020000000000436557ms I have to wonder whether the method of measurement might also be a factor, and how background processes in the browser come into play. Of course, each subsequent set of 10 runs is different...