Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Make it Fast: The Power of Benchmarking

Make it Fast: The Power of Benchmarking

A talk I presented at FunctionalConf 2017 in Bangalore. How, when, and why to use benchmarking in Elixir

Cameron Price

November 19, 2017
Tweet

More Decks by Cameron Price

Other Decks in Programming

Transcript

  1. Xmas lights • 1000x1000 grid of lights • Addressable 0,0

    to 999,999 • Controllable using special commands • Process the commands and count how many lights are lit at the end.
  2. turn off 660,55 through 986,197 turn off 341,304 through 638,850

    turn off 199,133 through 461,193 toggle 322,558 through 977,958 toggle 537,781 through 687,941 turn on 226,196 through 599,390 …
  3. Not ideal for Elixir • 2-d Array. We ain’t got

    ‘em. • Mutating a giant data structure • Difficult, maybe impossible to parallelize
  4. turn off 66,55 through 98,197 turn off 34,30 through 63,85

    turn off 19,13 through 46,19 toggle 32,55 through 97,95
  5. cameronp@gabriel ~/p/s/b/fc2017> time mix run -e 'Lights.run' 400410 35.16 real

    30.07 user 5.41 sys cameronp@gabriel ~/p/s/b/fc2017> time mix run -e 'Lights.run' 400410 18.48 real 17.65 user 1.38 sys cameronp@gabriel ~/p/s/b/fc2017>
  6. turn off 660,55 through 986,197 turn off 341,304 through 638,850

    turn off 199,133 through 461,193 toggle 322,558 through 977,958
  7. Benchmarking Tips • Write benchmarks early, but not first •

    Simplify the inputs • But NOT TOO MUCH, consider size • Keep running them