Skip to content

Latest commit

 

History

History
28 lines (17 loc) · 779 Bytes

plugin-benchmark.md

File metadata and controls

28 lines (17 loc) · 779 Bytes

Benchmarking

If you have a function you believe is slow, you can benchmark it to find any bottlenecks like this:

function slowFunction() {
  const bench = Reactotron.benchmark("slow function benchmark")

  // Code that does thing A
  bench.step("Thing A")

  // Code that does thing B
  bench.step("Thing B")

  // Code that does thing C
  bench.stop("Thing C")
}

Note that the last call is to stop instead of step! This is important because otherwise the benchmark results won't display in Reactotron.

When slowFunction is invoked, Reactotron should show something like this:

Benchmarking Output

Tips: Time bar Thing B is the code execution time from bench.step("Thing A") to bench.step("Thing B").