test44

JavaScript performance comparison

Test case created

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
test
var str = "Hello6 9World 2, Nic8e D7ay!";

function NumberSearch(str) {
  var chars = str.replace(/[^a-zA-z]/g, ''),
      nums = str.replace(/[^0-9]+/g, ''),
      total = 0;

  for (var i = nums.length - 1; i >= 0; i--) {
    total += Number(nums[i]);
  }

  return Math.round(total / chars.length);
}

NumberSearch(str);
pending…
test?
var str = "Hello6 9World 2, Nic8e D7ay!";

function NumberSearch(str) {
  var chars = str.replace(/[^a-zA-z]/g, ''),
      nums = str.replace(/[^0-9]+/g, ''),
      total = 0, total_chars = chars.length, total_nums = nums.length;

  for (var i = total_nums - 1; i >= 0; i--) {
    total += parseInt(nums[i]);
  }

  return Math.round(total / total_chars );
}

NumberSearch(str);
pending…

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

Compare results of other browsers

0 comments

Add a comment