nested function vs class

Benchmark created by lhorie on


Setup

let i = 0
  function a() {
    return {onclick: () => i}
  }
  
  let j = 0
  class B {
    click() {return j}
    render() {
      return {onclick: this.click}
    }
  }
  const b = new B()

Test runner

Ready to run.

Testing in
TestOps/sec
nested function
i++
a().onclick()
ready
class
j++
b.render().onclick()
ready

Revisions

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

  • Revision 1: published by lhorie on