js

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
solve 1
(function(window, undefined) {
 var document = window.document;

 var solve = function solve(input) {
  var output = [],
      i, j, value;

  i = input[0];
  j = input[input.length];
  if ((i >= 0 && j >= 0) || (i <= 0 && j <= 0)) {
   return output;
  }

  for (i = 0, j = input.length; i < j && (value = -input[i]) && value > 0; i++) {
   if (input.indexOf(value, i) > -1) {
    output[output.length] = value;
   }
  }

  return output;
 };

 window.solve = solve;
})(window);

solve([-4, -3, -1, 1, 2, 4, 67]);
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