Using profiling to determine if we should use "save" or "load" for getIndex()

author: Jaimie Harbin

The profvis package is used to display the timing of profiling. This is helpful for us when deciding if we should save, or re-read every time we use getIndex().

To get started, download the profvis package:

install.packages("profvis")
library(profvis)

Then, go to the "Profile" tab at the top of the R session, and click "Start Profiling".

In the Console, then type ai <- getIndex(age=0). When the action is complete, press Profile>Stop Profiling. The output is a Flame Graph, as shown in Figure 1.

![Profvis Output

Do the same procedure, but for ai <- getIndex() Note, each laptop (and different times of day) will result in different results.

You then have the ability to hold your mouse over each "box" ie. getIndex(), read.csv, save, load, etc. to display the amount of time to compute the action (shown in Figure 2)

Computation time

For JH at 1230h on 2020-12-23, the following are the computation times.

For getIndex(age=0) Total time for getIndex(age=0) was ~32 seconds. Of that, save was ~12 seconds (shown in Figure 3), and read.csv was 13.8 seconds. This means, if we were to remove the "save" portion of the action, it would take approximately 32-12=20 seconds.

"save" time for getIndex(age=0)

For getIndex() The total time for getIndex() was ~7 seconds, with the "load" action being 100% of that (ie. ~7 seconds, shown in Figure 4).

"load" time for getIndex()

These results tell us that for my computation the options are are follows:

If we keep "save", we have a one time computation of ~32 seconds, with the rest of the time we use the getIndex() function being ~7 seconds. If we remove "save" we have our computation time EACH time being ~32-12=20 seconds.

For Dan at approximately 1030h on 2020-12-23,

For getIndex(age=0), his total computation time was 24 seconds, with approximately 10 seconds being "save". For getIndex(), his total computation time, (ie. load time) was 4 seconds.

In his case, if we keep "save", we have a one time computation of ~24 seconds, with the rest of the time we use the getIndex() function being ~4 seconds. If we remove "save" we have our computation time EACH time being ~24-4=20 seconds.



dankelley/argoFloats documentation built on April 18, 2024, 5:13 a.m.