filter performance

JavaScript performance comparison

Test case created by pfeffer629

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var recipients = [];
  var start = performance.now();
  
  for (i=1000000;i>0;i--){
    var email = Math.random().toString(36).substring(12);
    var first_name = Math.random().toString(36).substring(7);
    var last_name = Math.random().toString(36).substring(9);
    var step = Math.floor(Math.random() * 10)
  
    recipients.push({
      email: email,
      first_name: first_name,
      last_name: last_name,
      step: step,
      created_on: "123",
      next_thing: "123"
    })
  }
  
  var search = "abc";

};

Benchmark.prototype.teardown = function() {
  var duration = performance.now() - start;
  
  console.log(duration + " milliseconds")

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
recipients
recipients.filter(recipient =>
  recipient.email && recipient.email.toLowerCase().indexOf(search) > -1 ||
  recipient.first_name && recipient.first_name.toLowerCase().indexOf(search) > -1 ||
  recipient.last_name && recipient.last_name.toLowerCase().indexOf(search) > -1
)
pending…
step
recipients.filter(recipient =>
  recipient.step == 2
)
pending…

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

0 Comments