MT5763 Lecture 14

C. Donovan

When waiting a long time for our code won't work - what should we be fixing?

Slooow code - profiling

  • Should we care?
    • Programmer time is more precious than computer time

If it ain't broke, don't fix

  • What is profiling?

Slooow code - profiling

  • Basic timing of things sys.time and system.time
  • Detailed profiling Rprof
  • Fine-scale profiling with precision measures microbenchmark
  • User-friendly profiling within R-Studio

Speeding things up

  • Dynamic sizing of objects and rbind hell
  • Vectorisation
  • Steal someone else's stuff (“steal” - give credit obvs)
  • Parallelise
  • Compile something (perhaps rcpp)
  • Get a bigger computer

Recap and look-forwards

We've covered:

  • Ways to determine where our code is slow and some common ways to fix common problems

Next:

  • Mainly parallelisation