JSON.parse vs String.split (v21)

Revision 21 of this benchmark created by Sergii Kliuchnyk on


Preparation HTML

<script>
  var arr =
 [1,2,3,4,5,6,7,8,9,10,1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9,10.01];

  var str = arr.join(",");

  var jsonstr = JSON.stringify(arr);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
JSON.parse
var result = JSON.parse(jsonstr);
ready
String.split
var result = str.split(',').map(function (n) { return Number(n); });
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.