Skip to contents

Compares two profiling runs to show what changed. Useful for measuring the impact of optimizations.

Usage

pv_compare(before, after, n = 20)

Arguments

before

A profvis object (before optimization).

after

A profvis object (after optimization).

n

Number of top functions to compare.

Value

A list with:

  • summary: Overall comparison summary

  • by_function: Function-by-function comparison

  • improved: Functions that got faster

  • regressed: Functions that got slower

Examples

p1 <- pv_example()
p2 <- pv_example()
pv_compare(p1, p2)
#> $summary
#>            metric before after        change
#> 1 Total time (ms)     70    70 +0 ms (+0.0%)
#> 2         Samples     14    14            +0
#> 3         Speedup      1     1         1.00x
#> 
#> $by_function
#>                              label before_ms after_ms diff_ms pct_change
#> 1                            rnorm        30       30       0          0
#> 2                 x[i] <- rnorm(1)        20       20       0          0
#> 3                    generate_data        15       15       0          0
#> 4 result[i] <- sqrt(abs(x[i])) * 2         5        5       0          0
#> 
#> $improved
#> [1] label      before_ms  after_ms   diff_ms    pct_change
#> <0 rows> (or 0-length row.names)
#> 
#> $regressed
#> [1] label      before_ms  after_ms   diff_ms    pct_change
#> <0 rows> (or 0-length row.names)
#>