event vs callback

Benchmark created by Tomasz on


Setup

var o = {
      callback: function () {
         return {
            a: 1
         };
      }
    },
    
    o2 = {
       trigger: function () {
          ev = new CustomEvent('myevent');
          ev.details = {a: 1};
          document.dispatchEvent(ev);
       }
    }

Test runner

Ready to run.

Testing in
TestOps/sec
callback
if (o.callback) {
   o.callback();
}
ready
dispachEvent
o2.trigger();
ready

Revisions

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

  • Revision 1: published by Tomasz on