Skip to content

Instantly share code, notes, and snippets.

@samarpanda
Last active August 29, 2015 14:06
Show Gist options
  • Save samarpanda/cd1b2ad473a5e52252b0 to your computer and use it in GitHub Desktop.
Save samarpanda/cd1b2ad473a5e52252b0 to your computer and use it in GitHub Desktop.
How a benchmark test is executed!

Benchmark.js how it works

  • For each benchmark in a suite:
    • Fire event: Suite.onStart()
    • For each benchmark:
    • Fire event: Benchmark.onStart()
    • For each sampled run
      • Run unit once to check for errors

        1. setup()
        2. testfn()
        3. teardown()
      • Run unit multiple times and measure results

        • setup()
        • for each Benchmark.count
          a. testfn()
        • teardown()
      • Fire event: Benchmark.onCycle()

    • Fire event: Benchmark.onComplete()
    • Fire event: Suite.onCycle()
  • Fire event: Suite.onComplete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment