(Micro)benchmarking

(Micro)benchmarking

Required packages

Note

All packages are automatically loaded in this tutorial.

library(tidyverse)
library(nycflights23)
library(microbenchmark)
library(assertthat)

Instructions

Implement my_sum

Complete the following function to compute the sum of values in a given array: Ask the course staff for help if you get stuck.

Test my_sum

Benchmark my_sum (vs. R’s sum)

Questions

  • Q1 What is the running time complexity of my_sum?
  • Q2 What did you observe when benchmarking my_sum against R’s sum?
    Provide two plausible explanations for your observations. (Hypothesize and confirm different reasons w/ online documentation or the course staff).
  • Q3 Given your observations, what are the implications for writing efficient data analyses in R?