filter performance

Benchmark created by pfeffer629 on


Setup

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";

Teardown



            var duration = performance.now() - start;
  
  console.log(duration + " milliseconds")
        
  

Test runner

Ready to run.

Testing in
TestOps/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
)
ready
step
recipients.filter(recipient =>
  recipient.step == 2
)
ready

Revisions

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

  • Revision 1: published by pfeffer629 on