forked from hqphat/coursera-r-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b0be7f
commit 1018188
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
R Profiler - Part 2 | ||
=================== | ||
|
||
Rprof() | ||
------- | ||
|
||
* The Rprof() function starts the profiler in R | ||
* R must be compiled with profiler support (but this is usually the case) | ||
* The summaryRprof() function summarizes the output from Rprof() (otherwise it's not readable) | ||
* NO NOT use system.time() and Rprof() together or you will be sad | ||
* Rprof() keeps track of the function call stack at regularly sampled intervals and tabulates how much time is spent in each function | ||
* Default sampling interval is 0.02 seconds | ||
* NOTE: If your code runs very quickly, the profiler is not useful, but then you probably don't need it in that case | ||
|
||
|
||
Using summaryRprof() | ||
-------------------- | ||
|
||
* The summaryRprof() function tabulates the R profiler output and calculates how much time is spent in which function | ||
* There are two methods for normalizing the data | ||
* "by.total" divides the time spent in each function by the total run time | ||
* "by.self" does the same but first subtracts out time spent in functions above in the call stack | ||
|
||
|
||
summaryRprof() Output | ||
--------------------- | ||
|
||
$sample.interval | ||
[1] 0.02 | ||
|
||
$sampling.time | ||
[1] 7.41 | ||
|
||
|
||
Summary | ||
------- | ||
|
||
* Rprof() runs the profiler for performance analysis of R code | ||
* summaryRprof() summarizes the output of Rprof() and gives percent of time spent in each function (with two types of normalization) | ||
* Good to break your code into functions so that the profiler can give useful information about where time is being spent | ||
* C or Fortran code is not profiled | ||
|