Returns the hottest source line with full context. Useful for quickly identifying the #1 optimization target.
Value
A list with:
location: File path and line number (e.g., "R/foo.R:42")label: Function namefilename: Source file pathlinenum: Line numbertime_ms: Time in millisecondspct: Percentage of total timecode: The source linecontext: Vector of surrounding source linescallers: Data frame of functions that call this location
Returns NULL if no source references are available.
Examples
p <- pv_example()
pv_worst_line(p)
#> $location
#> [1] "example_code.R:13"
#>
#> $label
#> [1] "rnorm"
#>
#> $filename
#> [1] "example_code.R"
#>
#> $linenum
#> [1] 13
#>
#> $time_ms
#> [1] 50
#>
#> $pct
#> [1] 71.4
#>
#> $code
#> [1] "x[i] <- rnorm(1)"
#>
#> $context
#> [1] "}" ""
#> [3] "generate_data <- function(n) {" " x <- numeric(n)"
#> [5] " for (i in seq_len(n)) {" " x[i] <- rnorm(1)"
#> [7] " }" " x"
#> [9] "}" ""
#> [11] "transform_data <- function(x) {"
#>
#> $callers
#> label samples pct
#> 1 generate_data 6 100
#>
