hadley/lineprof — pull request #29 by saurfang (2014-12-24 00:20:59+00:00)
Title: Focus on current subtree instead of root

This fixes an issue where ref can be ambiguous when drilling down.

Take the following code as example:

```r
library(lineprof)
library(magrittr)

quick <- function() { pause(.1) }
slow <- function() { pause(.2) }

quickWrap <- . %>% {quick()}
slowWrap <- . %>% {slow()}

x <- lineprof({ quickWrap(); slowWrap() })
print(x, depth = 5)
shine(x)
```

The results in the following
```
Reducing depth to 5 (from 7)
time alloc release dups ref
1 0.083 0.003 0 18 c("quickWrap", "freduce", "withVisible", "", "quick")
2 0.161 0.000 0 3 c("slowWrap", "freduce", "withVisible", "", "slow")
src
1 quickWrap/freduce/withVisible//quick
2 slowWrap/freduce/withVisible//slow
```

If we drill down a couple levels to `withVisible` from `slowWrap`, we find

1. total time is incorrect
![image](https://cloud.githubusercontent.com/assets/4317392/5544561/391813d4-8ad8-11e4-852d-097da0a65e0f.png)
![image](https://cloud.githubusercontent.com/assets/4317392/5544562/3e900dd0-8ad8-11e4-86ba-7f779a48f639.png)

2. drilling down one level deeper tells us the function uses both `slow` and `quick`. This is incorrect because we drilled down from `slowWrap` thus only `slow` should be shown.
![image](https://cloud.githubusercontent.com/assets/4317392/5544565/4c2239e6-8ad8-11e4-8411-70f63b51f428.png)

This can be fixed by making `focus` use the current `stack$top()` rather than the whole profiling tree `x`.

After the fix, we see things are now correctly identified.
![image](https://cloud.githubusercontent.com/assets/4317392/5544566/516dd25c-8ad8-11e4-805e-34e8226e6bb3.png)
![image](https://cloud.githubusercontent.com/assets/4317392/5544568/54f7ea52-8ad8-11e4-8959-9287d3f67ba4.png)

Please let me know if you have any questions or concerns.