© Thomas Mailund 2022
T. MailundBeginning Data Science in R 4https://doi.org/10.1007/978-1-4842-8155-0_16

16. Profiling and Optimizing

Thomas Mailund1  
(1)
Aarhus, Denmark
 

In this second chapter, we will briefly consider what to do when you find that your code is running too slow and, in particular, how to figure out why it is running too slow.

Before you start worrying about your code’s performance, though, it is important to consider if it is worth speeding it up. It takes you time to improve performance, and it is only worth it if the improved performance saves you time when this extra programming is included. For an analysis you can run in a day, there is no point in spending one day making it faster, even if it gets much faster, because you still ...

Get Beginning Data Science in R 4: Data Analysis, Visualization, and Modelling for the Data Scientist now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.