Description Usage Arguments Details Profiling output Navigation Display Examples
lineprof
uses R built-in time and memory profiler Rprof
to collect line profiling data and displays it in ways that help you
figure out where the bottlenecks in your code R.
1 |
code |
code to profile. |
interval |
interval, in seconds, between profile snapshots. R's timer has a resolution of at best 1 ms, so there's no reason to make this value smaller, but if you're profiling a long running function you might want to set it to something larger. |
torture |
if |
R's profiler is a sampling profiler, which means that it stops execution
every interval
seconds and records the current call stack. This means
that it is somewhat random: if you run the profiler repeatedly on the same
code you'll see slightly different outputs depending on exactly where the
profiler stopped each time.
For each sequence of calls, lineprof
calculates:
time
: the time in seconds
alloc
: the memory allocated, in megabytes
released
: the memory released, in megabytes. Unless
torture = TRUE
this release is somewhat random:
memory will be only released if a garbage collection is triggered by
an allocation.
dups
: the number of calls to the internal duplicate
function which is called by C code to duplicate R vectors.
Note that memory allocation is only approximate due to the nature of the
sampling profiler: if a large block of memory is allocated and then released
in between ticks of the timer, no change in memory will be recorded. Using
torture = TRUE
helps prevent this, mostly by making R super slow.
There are two ways to navigate through the line profiling output:
using a shiny GUI, generated by shine
; or through the
command line, using focus
.
The default print method uses reduce_depth
to reduce the call stack
to show only two steps down, and then formats the output with
format.lineprof
. An alternative option is to use
align
, which when src refs are available, will align the
profiling data with the original source code.
1 2 3 4 5 6 7 8 9 10 11 12 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.