Benchmarking

Timings hydrorecipes vs recipes

Timings for the hydrorecipes package are prefaced with an “h”. The first few comparisons include the R6 interface in hydrorecipes to check if there is a loss of speed compared to the standard API. Most users are likely to use the standard API so the remaining benchmarks only present that. Typical speed improvements are between 2-10x and memory consumption is typically half of the recipes package.

creating a recipe

relative <- TRUE
n <- c(1e2, 1e4, 5e6)
formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = 1:rows)
    bench::mark(
      hrec1 = hydrorecipes:::Recipe$new(formula = formula, data = dat),
      hrec2 = recipe(formula = formula, data = dat),
      rec   = recipes::recipe(formula = formula, data = dat),
      check = FALSE,
      relative = relative
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 9 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec1          100  1.00   1         6.09      1        1.66
#> 2 hrec2          100  1      1.00      6.04      1        1.50
#> 3 rec            100  6.23   6.07      1     24681.       1   
#> 4 hrec1        10000  1.00   1         5.84      1        1   
#> 5 hrec2        10000  1      1.01      5.84      1        1.52
#> 6 rec          10000  6.06   5.89      1         3.23     1.01
#> 7 hrec1      5000000  1      1.00      5.98      1        1.52
#> 8 hrec2      5000000  1.00   1         5.99      1        1   
#> 9 rec        5000000  6.11   5.96      1         3.23     1.01

add a step

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = 1:rows)
    bench::mark(
      hrec1 = hydrorecipes:::Recipe$new(formula = formula, data = dat)$
        add_step(hydrorecipes:::StepCenter$new(x)),
      hrec2 = recipe(formula = formula, data = dat) |>
        step_center(x),
      rec  = {recipes::recipe(formula = formula, data = dat) |>
          recipes::step_center(x)},
      check = FALSE,
      relative = relative
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 9 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec1          100  1      1         4.14     55.9      1   
#> 2 hrec2          100  1.02   1.03      4.01      1        1.52
#> 3 rec            100  4.22   4.13      1        16.3      1.01
#> 4 hrec1        10000  1      1         4.24      1        1.52
#> 5 hrec2        10000  1.03   1.04      4.09      1        1   
#> 6 rec          10000  4.27   4.23      1         1.03     1.55
#> 7 hrec1      5000000  1      1         4.12      1        1   
#> 8 hrec2      5000000  1.03   1.03      3.99      1        1.52
#> 9 rec        5000000  4.21   4.11      1         1.03     1.01

step_center prep

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = 1:rows)
    hrec1 = hydrorecipes:::Recipe$new(formula = formula, data = dat)$
      add_step(hydrorecipes:::StepCenter$new(x))
    hrec2 = recipe(formula = formula, data = dat) |>
      step_center(x)      
    rec   = recipes::recipe(formula = formula, data = dat) |>
      recipes::step_center(x)
    bench::mark(
      hrec1$prep(),
      hrec2 |> prep(),
      rec |> recipes::prep(),
      check = FALSE,
      min_iterations = 1L,
      relative = relative
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 9 × 7
#>   expression            rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>           <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec1$prep()           100  1.00   1         68.8       Inf     1.43
#> 2 prep(hrec2)            100  1      1.00      70.4       NaN     1.42
#> 3 recipes::prep(rec)     100 72.7   71.9        1         Inf     1   
#> 4 hrec1$prep()         10000  1.00   1         69.5       NaN     1.43
#> 5 prep(hrec2)          10000  1      1.00      69.6       NaN     1.43
#> 6 recipes::prep(rec)   10000 72.2   70.9        1         Inf     1   
#> 7 hrec1$prep()       5000000  1.01   1.01      21.7       NaN   Inf   
#> 8 prep(hrec2)        5000000  1      1         22.0       NaN   NaN   
#> 9 recipes::prep(rec) 5000000 22.8   22.1        1         Inf   Inf

step_center prep and bake

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = 1:rows)
    hrec1 = hydrorecipes:::Recipe$new(formula = formula, data = dat)$
      add_step(hydrorecipes:::StepCenter$new(x))
    hrec2 = recipe(formula = formula, data = dat) |>
      step_center(x)
    rec   = recipes::recipe(formula = formula, data = dat) |>
      recipes::step_center(x)
    
    bench::mark(
      hrec1$prep()$bake(),
      hrec2 |> prep() |> bake(),
      rec |> recipes::prep() |> recipes::bake(new_data = NULL),
      check = FALSE,
      min_iterations = 1L,
      relative = relative
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 9 × 7
#>   expression                      rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                     <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec1$prep()$bake()              1e2  1.00   1.00      63.3     40.9      1.49
#> 2 bake(prep(hrec2))                1e2  1      1         65.7      1        1.44
#> 3 recipes::bake(recipes::prep(r…   1e2 69.2   67.1        1      198.       1   
#> 4 hrec1$prep()$bake()              1e4  1      1         65.3      1        1.44
#> 5 bake(prep(hrec2))                1e4  1.01   1.01      64.3      1        1.44
#> 6 recipes::bake(recipes::prep(r…   1e4 68.2   66.7        1        2.85     1   
#> 7 hrec1$prep()$bake()              5e6  1      1         22.1      1      NaN   
#> 8 bake(prep(hrec2))                5e6  1.00   1.01      21.7      1      Inf   
#> 9 recipes::bake(recipes::prep(r…   5e6 22.7   22.2        1        2.50   NaN

step_center

formula <- as.formula(y~x+z)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = 1:rows,
                      z = rnorm(rows))
    
    bench::mark(
      hrec = (recipe(formula = formula, data = dat) |>
                step_center(x) |>
                plate())[["x"]],
      rec  = (recipes::recipe(formula = formula, data = dat) |>
                recipes::step_center(x) |> 
                recipes::prep() |> 
                recipes::bake(new_data = NULL))[["x"]],
      check = TRUE,
      min_iterations = 1L,
      relative = relative
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec           100  1      1        15.8       1        1   
#> 2 rec            100 15.7   15.8       1         5.81     1.06
#> 3 hrec         10000  1      1        15.5       1        1.43
#> 4 rec          10000 15.6   15.5       1         2.72     1   
#> 5 hrec       5000000  1      1         6.61      1        1   
#> 6 rec        5000000  7.12   6.57      1         2.50     1.04

step_scale

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = 1:rows,
                      z = rnorm(rows))
    bench::mark(
      hrec = (recipe(formula = formula, data = dat) |>
                step_scale(x, fun = fsd, n_sd = 2L) |>
                plate())[["x"]],
      rec  = (recipes::recipe(formula = formula, data = dat) |>
                recipes::step_scale(x, factor = 2L) |> 
                recipes::prep() |> 
                recipes::bake(new_data = NULL))[["x"]],
      check = TRUE,
      relative = relative,
      min_iterations = 1L
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec           100  1      1        15.2       2.33     1   
#> 2 rec            100 15.5   15.3       1         1        1.08
#> 3 hrec         10000  1      1        14.4       1        1.42
#> 4 rec          10000 14.5   14.5       1         2.25     1   
#> 5 hrec       5000000  1      1         1.81      1      NaN   
#> 6 rec        5000000  1.88   1.88      1         2.00   Inf

step_intercept

formula <- as.formula(y~x)
results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = rnorm(rows))
    bench::mark(
      hrec = (recipe(formula = formula, data = dat) |>
                step_intercept() |>
                plate("tbl"))[["intercept"]],
      rec = (recipes::recipe(formula = formula, data = dat) |>
               recipes::step_intercept() |> 
               recipes::prep() |> 
               recipes::bake(new_data = NULL))[["intercept"]],
      check = TRUE,
      relative = relative,
      min_iterations = 1L
    )
    
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec           100  1      1        15.7       1        1.48
#> 2 rec            100 16.0   15.9       1         5.23     1   
#> 3 hrec         10000  1      1        15.7       1        1   
#> 4 rec          10000 15.7   15.7       1         1.32     1.05
#> 5 hrec       5000000  1      1         4.34      1        2.01
#> 6 rec        5000000  4.65   4.32      1         1.00     1

step_normalize

formula <- as.formula(y~x+z)
results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = rnorm(rows),
                      z = rnorm(rows))
    
    bench::mark(
      hrec1 = (recipe(formula = formula, data = dat) |>
                 step_normalize(c(x, z, y)) |>
                 plate("tbl"))[, c("x", "z", "y")],
      
      hrec2 = (recipe(formula = formula, data = dat) |>
                 step_center(c(x, z, y)) |>
                 step_scale(c(x, z, y)) |>
                 plate("tbl"))[, c("x", "z", "y")],
      
      rec = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_normalize(x, y, z) |> 
        recipes::prep() |> 
        recipes::bake(new_data = NULL),
      
      relative = relative,
      min_iterations = 1L,
      check = TRUE
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 9 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec1          100  1      1        15.2      53.8      1.52
#> 2 hrec2          100  1.36   1.36     11.2       1        1   
#> 3 rec            100 15.0   15.4       1         7.92     1.09
#> 4 hrec1        10000  1      1        13.1       1        1   
#> 5 hrec2        10000  1.31   1.29     10.1       1.00     1.57
#> 6 rec          10000 13.2   13.2       1         1.39     1.06
#> 7 hrec1      5000000  1.00   1         1.73      1      Inf   
#> 8 hrec2      5000000  1      1.01      1.72      1.00   NaN   
#> 9 rec        5000000  1.74   1.73      1         1.33   Inf

step_drop_columns

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = rnorm(rows),
                      z = rnorm(rows))
    bench::mark(
      hrec = recipe(formula = formula, data = dat)  |>
        step_drop_columns(z) |>
        plate("tbl"),
      rec = recipes::recipe(formula = formula, data = dat)  |>
        recipes::step_rm(z) |>
        recipes::prep() |>
        recipes::bake(new_data = NULL),
      check = TRUE,
      relative = relative
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec           100   1      1        16.0       1       2.98
#> 2 rec            100  16.1   16.0       1        46.6     1   
#> 3 hrec         10000   1      1        16.1       1       1   
#> 4 rec          10000  16.2   16.2       1        51.5     1.07
#> 5 hrec       5000000   1      1        26.0       1       2.95
#> 6 rec        5000000  26.2   26.3       1     14557.      1

step_subset_na_omit

formula <- as.formula(y~x+z)

results <- bench::press(
  rows = c(1e6, 1e7),
  {
    dat <- tibble(x = rnorm(rows), 
                  z = rnorm(rows),
                  y = rnorm(rows))
    dat[1:5, "x"] <- NA_real_
    dat[100:150, "z"] <- NA_real_
    dat[10000:15000, "y"] <- NA_real_
    
    bench::mark(
      hrec1 = (recipe(formula = formula, data = dat) |>
                 step_subset_na_omit(terms = x) |>
                 prep() |>
                 bake())$get_result("tbl"),
      
      rec = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_naomit(x) |> 
        recipes::prep() |> 
        recipes::bake(new_data = NULL),
      
      relative = FALSE,
      min_iterations = 1L,
      check = TRUE
    )
  }
)
#> Running with:
#>       rows
#> 1  1000000
#> 2 10000000

results
#> # A tibble: 4 × 7
#>   expression     rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>    <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1       1000000   7.05ms   7.52ms    101.      34.9MB     2.07
#> 2 rec         1000000  28.74ms  29.25ms     32.9     34.4MB     2.06
#> 3 hrec1      10000000  64.14ms  72.34ms     14.1    343.3MB     3.52
#> 4 rec        10000000 102.61ms 105.68ms      9.49   343.4MB     2.37

step_subset_rows

formula <- as.formula(y~x+z)

results <- bench::press(
  rows = c(1e6, 1e7),
  {
    dat <- tibble(x = rnorm(rows), 
                  z = rnorm(rows),
                  y = rnorm(rows))
    sub <- sample(1:rows, size = 5e5)
    
    bench::mark(
      hrec1 = (recipe(formula = formula, data = dat) |>
                 step_subset_rows(row_numbers = sub) |>
                 prep() |>
                 bake())$get_result("tbl"),
      
      rec = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_slice(sub) |> 
        recipes::prep() |> 
        recipes::bake(new_data = NULL),
      
      base = dat[sub, ],
      
      relative = FALSE,
      min_iterations = 1L,
      check = TRUE
    )
  }
)
#> Running with:
#>       rows
#> 1  1000000
#> 2 10000000

results
#> # A tibble: 6 × 7
#>   expression     rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>    <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1       1000000   6.44ms   6.75ms     129.       12MB     2.05
#> 2 rec         1000000  34.12ms  43.55ms      24.3    30.7MB     2.21
#> 3 base        1000000   8.62ms  13.49ms      85.4    19.1MB     0   
#> 4 hrec1      10000000   9.72ms  10.06ms      98.1    11.4MB     2.04
#> 5 rec        10000000  59.64ms  60.31ms      16.6    64.9MB     2.07
#> 6 base       10000000  11.53ms  11.78ms      84.7    19.1MB     0

step_subset_sample

formula <- as.formula(y~x+z)

results <- bench::press(
  rows = c(1e6, 1e7),
  {
    dat <- data.frame(x = rnorm(rows), 
                      z = rnorm(rows),
                      y = rnorm(rows))
    
    bench::mark(
      h <- {hrec1 = recipe(formula = formula, data = dat) |>
        step_subset_sample(size = 10000L) |>
        prep() |>
        bake()
      h = nrow(hrec1$get_result("tbl"))},
      
      rec = nrow(recipes::recipe(formula = formula, data = dat) |>
                   recipes::step_sample(size = 10000 / rows) |>
                   recipes::prep() |>
                   recipes::bake(new_data = NULL)),
      
      relative = FALSE,
      min_iterations = 1L,
      check = TRUE
    )
  }
)
#> Running with:
#>       rows
#> 1  1000000
#> 2 10000000

results
#> # A tibble: 4 × 7
#>   expression                   rows     min  median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                  <dbl> <bch:t> <bch:t>     <dbl> <bch:byt>    <dbl>
#> 1 h <- { hrec1 = bake(prep(s…   1e6  1.71ms  1.77ms     563.    860.8KB     4.11
#> 2 rec                           1e6  24.3ms 24.79ms      40.4    8.31MB     4.25
#> 3 h <- { hrec1 = bake(prep(s…   1e7  1.97ms  2.02ms     493.   315.12KB     2.03
#> 4 rec                           1e7  49.1ms  49.6ms      20.1   76.89MB     2.24

step_cross_correlation


formula <- as.formula(y~x)
results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = rnorm(rows))
    
    bench::mark(
      hrec1 = recipe(formula = formula, data = dat) |>
        step_cross_correlation(c(x, z, y), lag_max = 1000) |>
        plate("tbl"),
      
      min_iterations = 1L,
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 3 × 7
#>   expression    rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1          100   1.37ms   1.43ms    696.     556.8KB     6.25
#> 2 hrec1        10000   2.11ms   2.18ms    456.      18.1KB     4.11
#> 3 hrec1      5000000  488.4ms 492.98ms      2.03    18.1KB     0


x <- rnorm(5e5)
y <- rnorm(5e5)
lag_max <- 1000
results <- bench::mark(fft_ccf  <- hydrorecipes:::convolve_correlation(x, y, lag_max),
                       ccf_base <- as.numeric(ccf(x, y, lag.max = lag_max, plot = FALSE)$acf),
                       min_iterations = 1L,
                       check = TRUE
)

results
#> # A tibble: 2 × 6
#>   expression                            min  median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                        <bch:t> <bch:t>     <dbl> <bch:byt>    <dbl>
#> 1 fft_ccf <- hydrorecipes:::convol… 33.05ms 33.46ms    29.9      15.7KB        0
#> 2 ccf_base <- as.numeric(ccf(x, y,…   1.93s   1.93s     0.518   136.1MB        0

step_lag

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = as.numeric(1:rows),
                      z = rnorm(rows))
    bench::mark(
      hrec1 = unname(recipe(formula = formula, data = dat) |>
                       step_lead_lag(x, lag = 1:30) |>
                       plate("tbl")),
      rec   = unname(recipes::recipe(formula = formula, data = dat) |>
                       recipes::step_lag(x, lag = 1:30) |> 
                       recipes::prep() |> 
                       recipes::bake(new_data = NULL)),
      check = TRUE,
      relative = relative,
      min_iterations = 1L
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec1          100  1      1        17.0       1        1.40
#> 2 rec            100 17.4   17.1       1         3.44     1   
#> 3 hrec1        10000  1      1        12.9       1        1   
#> 4 rec          10000 12.9   13.1       1         2.54     1.11
#> 5 hrec1      5000000  1      1         2.62      1        1.31
#> 6 rec        5000000  3.86   2.62      1         2.52     1

step_distributed_lag

formula <- as.formula(y~x)

results <- bench::press(
  rows = c(5e5, 5e6, 1e7),
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = 1:rows,
                      z = rnorm(rows))
    bench::mark(
      hrec = recipe(formula = formula, data = dat) |>
        step_distributed_lag(x, knots = log_lags(5, 86401)) |>
        prep() |> bake(),
      check = FALSE,
      relative = FALSE,
      min_iterations = 1L
    )
  }
)
#> Running with:
#>       rows
#> 1   500000
#> 2  5000000
#> 3 10000000

results
#> # A tibble: 3 × 7
#>   expression     rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>    <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec         500000  69.71ms  70.68ms    14.0      18.6MB        0
#> 2 hrec        5000000 485.02ms 485.15ms     2.06    155.9MB        0
#> 3 hrec       10000000    1.31s    1.31s     0.761   308.5MB        0

step_harmonic

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = 1:rows,
                      z = rnorm(rows))
    bench::mark(
      hrec = recipe(formula = formula, data = dat) |>
        step_harmonic(x, 
                      frequency = c(1.0, 2.0, 3.0), 
                      cycle_size = 0.1, 
                      starting_value = 0.0) |>
        plate("tbl"),
      rec  = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_harmonic(x, 
                               frequency = c(1.0, 2.0, 3.0), 
                               cycle_size = 0.1, 
                               starting_val = 0.0,
                               keep_original_cols = TRUE) |> 
        recipes::prep() |> 
        recipes::bake(new_data = NULL),
      
      # sin and cos terms order is different
      check = FALSE,
      relative = relative,
      min_iterations = 1L
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000
results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec           100  1      1        15.3       1        1.55
#> 2 rec            100 15.6   15.5       1        11.1      1   
#> 3 hrec         10000  1      1         8.43      1        1   
#> 4 rec          10000  8.00   8.11      1         3.47     2.19
#> 5 hrec       5000000  1      1         1.39      1      NaN   
#> 6 rec        5000000  1.39   1.39      1         3.43   NaN

# rows <- 1e6
# dat <- data.frame(x = rnorm(rows), 
#                   y = 1:rows,
#                   z = rnorm(rows))
# bench::mark(
#   
#   {hrec = recipe(formula = formula, data = dat) |>
#     step_harmonic(x, 
#                   frequency = c(1.0, 2.0, 3.0), 
#                   cycle_size = 0.1, 
#                   starting_value = 0.0,
#                   varying = "cycle_size") |>
#         step_harmonic(x, 
#                   frequency = c(1.0, 2.0, 3.0), 
#                   cycle_size = 0.1, 
#                   starting_value = 0.0) |>
#     step_intercept() |>
#     step_center(x) |>
#     prep() |>
#     bake()}, 
#   
#   {hrec$steps[[2]]$update_step("cycle_size", 0.2)
#     hrec$bake()
#   },
#   check = FALSE
# )

step_pca

set.seed(1)
formula <- as.formula(x~a + b + c + d + e + f + g + h + i + j + k + l)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      a = rnorm(rows),
                      b = rnorm(rows),
                      c = rnorm(rows),
                      d = rnorm(rows),
                      e = rnorm(rows),
                      f = rnorm(rows),
                      g = rnorm(rows),
                      h = rnorm(rows),
                      i = rnorm(rows),
                      j = rnorm(rows),
                      k = rnorm(rows),
                      l = rnorm(rows)
    )
    bench::mark(
      hrec1 = recipe(formula = formula, data = dat)|>
        step_pca(c(a,b,c,d,e,f,g,h,i,j,k,l), n_comp = 10L) |>
        plate(),
      hrec2 = recipe(formula = formula, data = dat)|>
        step_pca(c(a,b,c,d,e,f,g,h,i,j,k,l), n_comp = 5L) |>
        plate(),
      hrec3 = recipe(formula = formula, data = dat)|>
        step_pca(c(a,b,c,d,e,f,g,h,i,j,k,l),
                 n_comp = 10L,
                 center = FALSE,
                 scale = FALSE) |>
        plate(),
      hrec4 = recipe(formula = formula, data = dat)|>
        step_pca(c(a,b,c,d,e,f,g,h,i,j,k,l),
                 n_comp = 5L,
                 center = FALSE,
                 scale = FALSE) |>
        plate(),
      
      rec1  = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_pca(recipes::all_predictors(),
                          num_comp = 10L,
                          options = list(center = TRUE, scale. = TRUE))|> 
        recipes::prep() |> 
        recipes::bake(new_data = NULL),
      rec2  = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_pca(recipes::all_predictors(),
                          num_comp = 5L,
                          options = list(center = TRUE, scale. = TRUE)) |> 
        recipes::prep() |> 
        recipes::bake(new_data = NULL),
      rec3  = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_pca(recipes::all_predictors(),
                          num_comp = 10L) |> 
        recipes::prep() |> 
        recipes::bake(new_data = NULL),
      rec4  = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_pca(recipes::all_predictors(),
                          num_comp = 5L) |> 
        recipes::prep() |> 
        recipes::bake(new_data = NULL),
      check = FALSE,
      relative = relative,
      min_iterations = 1L
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000


print(results, n = 100)
#> # A tibble: 24 × 14
#>    expression    rows   min median `itr/sec` mem_alloc `gc/sec` n_itr  n_gc
#>    <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl> <int> <dbl>
#>  1 hrec1          100  1.02   1.02     15.9      13.5      1.55   289     3
#>  2 hrec2          100  1.03   1.03     15.9       1        1.00   299     2
#>  3 hrec3          100  1.01   1.01     16.2       1.20     1.52   301     3
#>  4 hrec4          100  1      1        16.4       1        1      308     2
#>  5 rec1           100 16.2   16.5       1        13.6      1.11    17     2
#>  6 rec2           100 16.1   16.1       1.02      5.80     1.07    18     2
#>  7 rec3           100 16.1   15.8       1.03      3.10     1.71    17     3
#>  8 rec4           100 15.7   15.6       1.06      2.75     1.10    18     2
#>  9 hrec1        10000  1.62   1.61      8.50      1.22   NaN       95     0
#> 10 hrec2        10000  1.58   1.57      8.69      1      Inf       95     1
#> 11 hrec3        10000  1.01   1.02     13.4       1.22   Inf      147     1
#> 12 hrec4        10000  1      1        13.6       1      Inf      144     2
#> 13 rec1         10000 13.9   13.7       1         6.01   Inf       10     1
#> 14 rec2         10000 13.6   13.5       1.02      5.69   Inf       11     1
#> 15 rec3         10000 12.1   11.9       1.15      2.24   Inf       11     2
#> 16 rec4         10000 11.7   11.6       1.18      1.91   Inf       12     1
#> 17 hrec1      5000000  2.14   2.03      4.12      1.22   NaN        1     0
#> 18 hrec2      5000000  2.11   2.00      4.18      1      Inf        1     1
#> 19 hrec3      5000000  1      1.03      8.12      1.22   Inf        2     1
#> 20 hrec4      5000000  1.06   1         8.37      1      NaN        1     0
#> 21 rec1       5000000  8.83   8.36      1.00      6.01   Inf        1     5
#> 22 rec2       5000000  8.84   8.37      1         5.68   Inf        1     4
#> 23 rec3       5000000  3.56   3.37      2.48      2.23   Inf        1     2
#> 24 rec4       5000000  3.82   3.61      2.31      1.90   Inf        1     1
#> # ℹ 5 more variables: total_time <bch:tm>, result <list>, memory <list>,
#> #   time <list>, gc <list>

step_dummy

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = qF(sample(1:10, rows, replace = TRUE)),
                      z = rnorm(rows))
    bench::mark(
      hrec = unname(recipe(formula = formula, data = dat) |>
                      step_dummy(y) |>
                      plate("tbl"))[,3:11],
      rec  = unname(recipes::recipe(formula = formula, data = dat) |>
                      recipes::step_dummy(y, keep_original_cols = TRUE) |>
                      recipes::prep() |>
                      recipes::bake(new_data = NULL))[,3:11],
      check = TRUE,
      relative = relative,
      min_iterations = 1L
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec           100   1      1        14.0      1.01     1.45
#> 2 rec            100  14.4   14.0       1        1        1   
#> 3 hrec         10000   1      1        21.1      1        3.05
#> 4 rec          10000  21.2   21.0       1       17.8      1   
#> 5 hrec       5000000   1      1       161.       1      NaN   
#> 6 rec        5000000 165.   161.        1       13.1    Inf

step_find_interval

  • no direct comparison so compare to step_cut
formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), 
                      y = 1:rows,
                      z = rnorm(rows))
    bench::mark(
      hrec = recipe(formula = formula, data = dat) |>
        step_find_interval(x, vec = c(-0.1, 0, 0.1)) |>
        plate("tbl"),
      rec  = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_cut(x, breaks = c(-0.1, 0, 0.1)) |>
        recipes::prep() |>
        recipes::bake(new_data = NULL),
      check = FALSE,
      relative = relative,
      min_iterations = 1L
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec           100  1      1        13.9       3.23     1.20
#> 2 rec            100 14.3   13.9       1         1        1   
#> 3 hrec         10000  1      1        12.9       1        1   
#> 4 rec          10000 13.1   12.9       1         2.65     2.34
#> 5 hrec       5000000  1      1         2.78      1      NaN   
#> 6 rec        5000000  2.72   2.77      1         2.50   NaN

step_varying

formula <- as.formula(y~x+z)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rep(1, rows), 
                      y = 1:rows,
                      z = rnorm(rows))
    bench::mark(
      hrec = recipe(formula = formula, data = dat) |>
        step_varying(c(x, y, z)) |>
        plate("tbl"),
      rec  = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_zv(x, y, z) |>
        recipes::prep() |>
        recipes::bake(new_data = NULL),
      check = TRUE,
      relative = relative,
      min_iterations = 1L
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec           100   1      1        14.8      6.69   Inf   
#> 2 rec            100  15.1   14.8       1        1      NaN   
#> 3 hrec         10000   1      1        15.3      1        1   
#> 4 rec          10000  15.5   15.3       1       32.7      1.04
#> 5 hrec       5000000   1      1        79.9      1      NaN   
#> 6 rec        5000000  81.0   80.1       1       34.1    NaN

step_kernel_filter

step_kernel_filter uses an Fast Fourier Transform (FFT) based convolution instead of an explicit sliding window. This should be much faster for large datasets and particularly when the kernel size is also large.

formula <- as.formula(y~x+z)

results <- bench::press(
  rows = c(2e4, 2e5),
  {
    dat <- data.frame(x = rep(1, rows), 
                      y = 1:rows,
                      z = cumsum(rnorm(rows)))
    bench::mark(
      hrec = unname((recipe(formula = formula, data = dat) |>
                       step_kernel_filter(z, kernel = list(rep(1, 5001L)/5001L), align = "center") |>
                       plate("tbl"))[10000, "kernel_filter_z"]),
      {rec  = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_window(z, size = 5001L, statistic = "mean") |>
        recipes::prep() |>
        recipes::bake(new_data = NULL)
      unname(rec[10000, "z"])},
      
      min_iterations = 1L,
      relative = relative,
      check = TRUE
    )
  }
)
#> Running with:
#>     rows
#> 1  20000
#> 2 200000

results
#> # A tibble: 4 × 7
#>   expression                      rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                     <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec                             2e4    1      1       131.      1.81      Inf
#> 2 { rec = recipes::bake(recipes…   2e4  136.   131.        1       1         NaN
#> 3 hrec                             2e5    1      1       795.      1         NaN
#> 4 { rec = recipes::bake(recipes…   2e5  831.   795.        1       1.49      NaN

step_convolve_gamma

formula <- as.formula(y~x+z)

results <- bench::press(
  rows = c(2e4, 2e6),
  {
    dat <- data.frame(x = rep(1, rows), 
                      y = 1:rows,
                      z = cumsum(rnorm(rows)))
    bench::mark(
      hrec = (recipe(formula = formula, data = dat) |>
                step_convolve_gamma(z, amplitude = 1, k = 1, theta = 1) |>
                plate("tbl")),
      min_iterations = 1,
      relative = FALSE,
      check = TRUE
    )
  }
)
#> Running with:
#>      rows
#> 1   20000
#> 2 2000000

results
#> # A tibble: 2 × 7
#>   expression    rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec         20000   1.85ms   1.92ms     518.    723.4KB     2.07
#> 2 hrec       2000000  27.87ms  28.14ms      35.5    15.3MB     0

step_compare_columns

multiple steps

step_harmonic dominates these results.

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = as.numeric(1:rows), 
                      y = 1:rows)
    bench::mark(
      hrec = recipe(formula = formula, data = dat) |>
        step_lead_lag(x, lag = 1:20) |>
        step_harmonic(x, 
                      frequency = c(1.0, 2.0, 3.0), 
                      cycle_size = 0.1, 
                      starting_value = 0.0) |>
        step_center(x) |> 
        plate("tbl"),
      rec  = recipes::recipe(formula = formula, data = dat) |>
        recipes::step_lag(x, lag = 1:20, keep_original_cols = TRUE) |>
        recipes::step_harmonic(x, 
                               frequency = c(1.0, 2.0, 3.0), 
                               cycle_size = 0.1, 
                               starting_val = 0.0,
                               keep_original_cols = TRUE) |>
        recipes::step_center(x) |> 
        recipes::prep() |> 
        recipes::bake(new_data = NULL),
      check = FALSE,
      relative = relative,
      min_iterations = 1
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec           100  1      1        15.9       1         Inf
#> 2 rec            100 16.2   15.9       1         5.76      NaN
#> 3 hrec         10000  1      1        12.1       1         NaN
#> 4 rec          10000 11.8   12.0       1         2.67      Inf
#> 5 hrec       5000000  1      1         1.48      1         NaN
#> 6 rec        5000000  1.48   1.48      1         2.62      Inf

step_spline_b

formula <- as.formula(y~x)
n <- c(100, 1e4, 5e6)
results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows),
                      y = 1:rows)
    bench::mark(
      hrec = unname(recipe(formula = formula, data = dat) |>
                      step_spline_b(x, df = 13) |>
                      plate("tbl")),
      rec  = unname(recipes::recipe(formula = formula, data = dat) |>
                      recipes::step_spline_b(x, deg_free = 13, keep_original_cols = TRUE)|> 
                      recipes::prep() |> 
                      recipes::bake(new_data = NULL)),
      check = TRUE,
      relative = relative,
      min_iterations = 2
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec           100  1      1        13.9       1         NaN
#> 2 rec            100 14.1   13.9       1        18.9       Inf
#> 3 hrec         10000  1      1         9.32      1         Inf
#> 4 rec          10000  9.37   9.34      1         4.64      NaN
#> 5 hrec       5000000  1      1         3.85      1         NaN
#> 6 rec        5000000  3.73   3.85      1         4.62      Inf

step_spline_n

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows),
                      y = 1:rows)
    bench::mark(
      hrec = unname(recipe(formula = formula, data = dat) |>
                      step_spline_n(x, df = 11L) |>
                      plate("tbl")),
      rec  = unname(recipes::recipe(formula = formula, data = dat) |>
                      recipes::step_spline_natural(x, deg_free = 11L, keep_original_cols = TRUE)|> 
                      recipes::prep() |> 
                      recipes::bake(new_data = NULL)),
      check = TRUE,
      relative = relative,
      min_iterations = 2L
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec           100  1      1        13.8       2.97   NaN   
#> 2 rec            100 14.3   13.8       1         1      Inf   
#> 3 hrec         10000  1      1         8.87      1      NaN   
#> 4 rec          10000  8.84   8.90      1         4.49   Inf   
#> 5 hrec       5000000  1      1         3.36      1        3.36
#> 6 rec        5000000  3.36   3.36      1         4.47     1

step_add_noise

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = as.numeric(1:rows),
                      y = rep(0.01, rows))
    bench::mark(
      hrec1 = recipe(formula = formula, data = dat) |>
        step_add_noise(y) |>
        plate("dt"))
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 3 × 7
#>   expression    rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1          100   1.25ms    1.3ms    764.     553.6KB     0   
#> 2 hrec1        10000   1.63ms   1.69ms    589.     160.5KB     2.08
#> 3 hrec1      5000000 193.35ms 193.58ms      5.17    76.3MB     0

step_aquifer_grf & step_aquifer_theis

The Theis solution is a subset of the grf solution.

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = as.numeric(1:rows),
                      y = rep(0.01, rows))
    bench::mark(
      hrec1 = recipe(formula = formula, data = dat) |>
        step_aquifer_grf(time = x, flow_rate = y) |>
        plate("dt"),
      hrec2 = recipe(formula = formula, data = dat) |>
        step_aquifer_theis(time = x, flow_rate = y) |>
        plate("dt"),
      check = TRUE)
  }
)
#> Running with:
#>      rows
#> 1     100
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 2   10000
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 3 5000000
#> a: 0
#> a: 0
#> a: 0
#> a: 0

results
#> # A tibble: 6 × 7
#>   expression    rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1          100   1.44ms   1.49ms    670.      5.91KB     2.08
#> 2 hrec2          100   1.53ms    1.6ms    626.    541.13KB     2.07
#> 3 hrec1        10000   2.36ms    2.4ms    415.    160.59KB     0   
#> 4 hrec2        10000   2.45ms   2.52ms    396.     83.62KB     2.26
#> 5 hrec1      5000000 559.94ms 559.94ms      1.79    76.3MB     0   
#> 6 hrec2      5000000 556.02ms 556.02ms      1.80   38.15MB     0

step_aquifer_theis_aniso

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = as.numeric(1:rows),
                      y = rep(0.01, rows))
    bench::mark(
      hrec1 = unname(recipe(formula = formula, data = dat) |>
                       step_aquifer_theis_aniso(time = x, 
                                                flow_rate = y,
                                                distance_x = 0, 
                                                distance_y = 100,
                                                hydraulic_conductivity_major = 1e-4,
                                                hydraulic_conductivity_minor = 1e-4) |>
                       plate("dt")),
      hrec2 = unname(recipe(formula = formula, data = dat) |>
                       step_aquifer_theis(time = x, flow_rate = y,) |>
                       plate("dt")),
      check = TRUE)
  }
)
#> Running with:
#>      rows
#> 1     100
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 2   10000
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 3 5000000
#> a: 0
#> a: 0

results
#> # A tibble: 6 × 7
#>   expression    rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1          100   1.79ms   1.84ms    541.        53KB     0   
#> 2 hrec2          100   1.88ms   1.95ms    508.      28.2KB     2.08
#> 3 hrec1        10000   2.68ms   2.78ms    359.     182.6KB     2.09
#> 4 hrec2        10000   2.82ms   2.89ms    344.     105.6KB     0   
#> 5 hrec1      5000000 557.82ms 557.82ms      1.79    76.3MB     0   
#> 6 hrec2      5000000 553.01ms 553.01ms      1.81    38.2MB     0

step_aquifer_leaky

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = as.numeric(1:rows),
                      y = rep(0.01, rows))
    bench::mark(
      hrec1 = unname(recipe(formula = formula, data = dat) |>
                       step_aquifer_leaky(time = x,
                                          flow_rate = y,
                                          leakage = 100000000) |>
                       plate("dt")),
      hrec2 = unname(recipe(formula = formula, data = dat) |>
                       step_aquifer_theis(time = x,
                                          flow_rate = y) |>
                       plate("dt")),
      check = TRUE)
  }
)
#> Running with:
#>      rows
#> 1     100
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 2   10000
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 3 5000000
#> a: 0
#> a: 0

results
#> # A tibble: 6 × 7
#>   expression    rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1          100   1.78ms   1.85ms   537.       30.4KB     2.08
#> 2 hrec2          100   1.89ms   1.96ms   508.       28.2KB     2.08
#> 3 hrec1        10000   3.62ms   3.73ms   266.      417.1KB     0   
#> 4 hrec2        10000    2.8ms   2.88ms   346.      105.6KB     2.09
#> 5 hrec1      5000000    1.27s    1.27s     0.787   190.8MB     0   
#> 6 hrec2      5000000 558.03ms 558.03ms     1.79     38.2MB     0

step_aquifer_patch

formula <- as.formula(y~x)

results <- bench::press(
  rows = c(1e4, 1e5, 1e6),
  {
    dat <- data.frame(x = as.numeric(1:rows),
                      y = rep(0.01, rows))
    bench::mark(
      hrec1 = (recipe(formula = formula, data = dat) |>
                 step_aquifer_grf(time = x, flow_rate = y) |>
                 plate("dt")),
      hrec3 = (recipe(formula = formula, data = dat) |>
                 step_aquifer_patch(time = x,
                                    flow_rate = 0.01,
                                    thickness = 1.0,
                                    radius = 100.0,
                                    radius_patch = 200.0,
                                    specific_storage_inner = 1e-6,
                                    specific_storage_outer = 1e-6,
                                    hydraulic_conductivity_inner = 1e-4,
                                    hydraulic_conductivity_outer = 1e-4,
                                    n_stehfest = 8L
                 ) |>
                 plate("dt")),
      check = FALSE,
      relative = relative)
  }
)
#> Running with:
#>      rows
#> 1   10000
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 2  100000
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 3 1000000
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0


results
#> # A tibble: 6 × 7
#>   expression    rows   min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <dbl>  <dbl>     <dbl>     <dbl>    <dbl>
#> 1 hrec1        10000   1      1        50.9      1.94      NaN
#> 2 hrec3        10000  52.0   51.1       1        1         NaN
#> 3 hrec1       100000   1      1        92.3      1.99      NaN
#> 4 hrec3       100000  93.8   92.4       1        1         NaN
#> 5 hrec1      1000000   1      1        88.9      2.00      NaN
#> 6 hrec3      1000000  89.5   88.7       1        1         NaN

step_aquifer_wellbore_storage

  • currently this is slow for long series.
results <- bench::press(
  rows = c(1e3, 1e4, 1e5),
  {
    dat <- data.frame(x = as.numeric(1:rows), 
                      y = as.numeric(1:rows))
    bench::mark(
      hrec1 = unname(recipe(formula = formula, data = dat) |>
                       step_aquifer_wellbore_storage(time = x,
                                                     flow_rate = 0.01,
                                                     hydraulic_conductivity = 1e-4,
                                                     specific_storage = 1e-6, 
                                                     radius = 100,
                                                     radius_casing = 1e-15,
                                                     radius_well = 1e-15, n_terms = 18) |>
                       plate("dt")),
      hrec2 = unname(recipe(formula = formula, data = dat) |>
                       step_aquifer_theis(time = x,
                                          flow_rate = y) |>
                       plate("dt")),
      check = FALSE
    )
  }
)
#> Running with:
#>     rows
#> 1   1000
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 2  10000
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 3 100000
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0

results
#> # A tibble: 6 × 7
#>   expression   rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>  <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1        1000   8.94ms   9.01ms    111.     41.98KB     0   
#> 2 hrec2        1000   2.02ms   2.08ms    478.     43.12KB     0   
#> 3 hrec1       10000   60.5ms  60.54ms     16.5   182.61KB     0   
#> 4 hrec2       10000   2.78ms   2.87ms    348.    183.75KB     2.10
#> 5 hrec1      100000 533.93ms 533.93ms      1.87    1.55MB     0   
#> 6 hrec2      100000  10.97ms  11.22ms     88.7     1.55MB     0

step_vadose_weeks

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = as.numeric(1:rows), 
                      y = as.numeric(1:rows))
    bench::mark(
      hrec1 = (recipe(formula = formula, data = dat) |>
                 step_vadose_weeks(time = x, 
                                   air_diffusivity = 0.8, 
                                   thickness = 5, 
                                   precision = 1e-12) |>
                 plate("dt")),
      check = FALSE,
      min_iterations = 2
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 3 × 7
#>   expression    rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1          100   1.29ms   1.33ms    748.     557.8KB     2.09
#> 2 hrec1        10000   1.47ms   1.51ms    658.     160.5KB     2.08
#> 3 hrec1      5000000 176.94ms 176.96ms      5.65    76.3MB     0

step_transport_ogata_banks

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(expand.grid(as.numeric(1:rows), 
                                  as.numeric(1:10)))
    names(dat) <- c('x', 'y')
    bench::mark(
      hrec1 = (recipe(formula = formula, data = dat) |>
                 step_transport_ogata_banks(time = x,
                                            distance = y) |>
                 plate("dt")),
      check = FALSE,
      min_iterations = 2
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 3 × 7
#>   expression    rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1          100    1.4ms   1.44ms   693.        572KB     2.08
#> 2 hrec1        10000   5.25ms   5.38ms   186.        786KB     0   
#> 3 hrec1      5000000    1.51s    1.51s     0.663     381MB     0

step_transport_fractures_solute

formula <- as.formula(~time+z+x)

dat <- setDT(expand.grid(10^(3:8),
                         seq(0.0, 10, 1),
                         c(0.0)))

names(dat) <- c("time", "z", "x")

results <- 
  bench::mark(
    hrec1 = recipe(formula = formula, data = dat) |>
      step_transport_fractures_solute(time = time,
                                      distance_fracture = z,
                                      distance_matrix = x) |>
      plate("dt"),
    check = FALSE,
    min_iterations = 2
  )

results
#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1        1.76ms   1.84ms      543.     595KB        0

step_transport_fractures_heat

formula <- as.formula(~time+z+x)

dat <- setDT(expand.grid(10^(3:8),
                         seq(0.0, 100, 1),
                         c(0.0, 0.05)))

names(dat) <- c("time", "z", "x")

results <- 
  bench::mark(
    hrec1 = recipe(formula = formula, data = dat) |>
      step_transport_fractures_heat(time = time,
                                    distance_fracture = z,
                                    distance_matrix = x) |>
      plate("dt"),
    check = FALSE,
    min_iterations = 2
  )

results
#> # A tibble: 1 × 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1          10ms   10.2ms      98.2     603KB        0

step_fft_pgram, step_fft_welch

formula <- as.formula(y~x + z)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows), y = rnorm(rows), z = rnorm(rows),
                      q = rnorm(rows), r = rnorm(rows), s = rnorm(rows))
    bench::mark(
      hrec1 = recipe(formula = formula, data = dat) |>
        step_fft_pgram(c(x, y), 
                       3,
                       TRUE,
                       TRUE,
                       FALSE,
                       0.1, 
                       time_step = 1) |> 
        prep() |>
        bake(),
      hrec2 = recipe(formula = formula, data = dat) |>
        step_fft_pgram(c(x, y), 
                       3,
                       TRUE,
                       TRUE,
                       TRUE,
                       0.1, 
                       time_step = 1) |> 
        prep() |>
        bake(),
      hrec3 = recipe(formula = formula, data = dat) |>
        step_fft_welch(c(x, y),
                       length_subset =  nrow(dat) / 10,
                       overlap = 0.60,
                       window = window_nuttall(nrow(dat) / 10),
                       time_step = 1) |>
        prep() |>
        bake(),
      check = FALSE,
      min_iterations = 1
    )
  }
)
#> Running with:
#>      rows
#> 1     100
#> 2   10000
#> 3 5000000

results
#> # A tibble: 9 × 7
#>   expression    rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>   <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1          100   1.66ms   1.73ms    578.    588.65KB     2.71
#> 2 hrec2          100   1.63ms   1.72ms    581.     17.76KB     0   
#> 3 hrec3          100   1.43ms   1.48ms    675.    567.22KB     0   
#> 4 hrec1        10000   2.19ms    2.3ms    429.      1.45MB     2.70
#> 5 hrec2        10000   2.17ms    2.3ms    434.      1.15MB     0   
#> 6 hrec3        10000    2.6ms   2.67ms    374.    268.44KB     0   
#> 7 hrec1      5000000 512.03ms 512.03ms      1.95   724.8MB     0   
#> 8 hrec2      5000000 413.97ms 413.97ms      2.42  572.21MB     2.42
#> 9 hrec3      5000000 439.89ms 442.44ms      2.26   129.7MB     0

step_fft_transfer_welch and step_fft_transfer_pgram, step_fft_transfer_experimental

formula <- as.formula(y~x)

results <- bench::press(
  rows = c(1e5, 1e6, 1e7),
  {
    dat <- data.frame(x = rnorm(rows), y = rnorm(rows))
    bench::mark(
      hrec1 = recipe(formula = formula, data = dat) |>
        step_fft_transfer_pgram(c(x, y), 
                                3,
                                TRUE,
                                TRUE,
                                0.1, 
                                time_step = 1) |> 
        prep() |>
        bake(),
      hrec2 = recipe(formula = formula, data = dat) |>
        step_fft_transfer_welch(c(x, y),
                                length_subset =  nrow(dat) / 10,
                                overlap = 0.60,
                                window = window_nuttall(nrow(dat) / 10), 
                                time_step = 1) |> 
        prep() |>
        bake(),
      hrec3 <- recipe(formula = formula, data = dat) |>
        step_fft_transfer_experimental(c(x, y), 
                                       spans = 3, 
                                       taper = 0.1, 
                                       n_groups = 300,
                                       time_step = 1) |>
        prep() |>
        bake(),
      check = FALSE,
      min_iterations = 1
    )
  }
)
#> Running with:
#>       rows
#> 1   100000
#> 2  1000000
#> 3 10000000

results
#> # A tibble: 9 × 7
#>   expression                 rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1                       1e5  19.03ms  20.39ms    49.4      6.11MB    0    
#> 2 hrec2                       1e5   9.98ms  11.03ms    90.8      2.06MB    0    
#> 3 hrec3 <- bake(prep(step_…   1e5    7.8ms   7.95ms   124.       1.92MB    0    
#> 4 hrec1                       1e6 188.51ms  190.6ms     5.26    61.04MB    0    
#> 5 hrec2                       1e6  88.94ms  90.96ms    10.9      20.6MB    0    
#> 6 hrec3 <- bake(prep(step_…   1e6   73.9ms  74.39ms    13.4     19.09MB    0    
#> 7 hrec1                       1e7    2.15s    2.15s     0.466  610.35MB    0.466
#> 8 hrec2                       1e7    1.01s    1.01s     0.988     206MB    0    
#> 9 hrec3 <- bake(prep(step_…   1e7 810.02ms 810.02ms     1.23   190.75MB    0

step_ols

formula <- as.formula(y~.)


results <- bench::press(
  rows = c(1e5, 1e6, 1e7),
  {
    dat <- data.frame(
      y = rnorm(rows),
      x = rnorm(rows), 
      z = rnorm(rows),
      a = rnorm(rows),
      b = rnorm(rows),
      d = rnorm(rows),
      e = rnorm(rows),
      f = rnorm(rows),
      g = rnorm(rows))
    m <- qM(dat)
    bench::mark(
      hrec1 = recipe(formula = formula, data = dat) |>
        step_ols(formula = as.formula(y~.), 
                 do_response = FALSE) |>
        prep() |>
        bake(),
      hrec2 = recipe(formula = formula, data = dat) |>
        step_ols(formula = as.formula(y~.), 
                 do_response = TRUE) |>
        prep() |>
        bake(),
      lm = lm(y~. - 1, dat),
      lm.fit(x = m[, c(2:ncol(dat))], y = m[, 1]),
      check = FALSE,
      relative = FALSE
    )
  }
)
#> Running with:
#>       rows
#> 1   100000
#> 2  1000000
#> 3 10000000


results
#> # A tibble: 12 × 7
#>    expression                rows      min   median `itr/sec` mem_alloc `gc/sec`
#>    <bch:expr>               <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#>  1 hrec1                      1e5    7.1ms  11.25ms    92.7     16.79MB    0    
#>  2 hrec2                      1e5  11.56ms  13.04ms    77.2     19.08MB    0    
#>  3 lm                         1e5  18.98ms  26.17ms    38.7     24.62MB    0    
#>  4 lm.fit(x = m[, c(2:ncol…   1e5   13.5ms  13.98ms    64.5     17.55MB    3.07 
#>  5 hrec1                      1e6  56.03ms  56.46ms    16.4    167.85MB    2.05 
#>  6 hrec2                      1e6  64.89ms  65.62ms    15.2    190.74MB    0    
#>  7 lm                         1e6 128.14ms 147.34ms     6.79   244.14MB    3.39 
#>  8 lm.fit(x = m[, c(2:ncol…   1e6 135.85ms 143.14ms     6.99   175.48MB    0    
#>  9 hrec1                      1e7    860ms    860ms     1.16     1.64GB    1.16 
#> 10 hrec2                      1e7 725.77ms 725.77ms     1.38     1.86GB    0    
#> 11 lm                         1e7    1.38s    1.38s     0.724    2.38GB    0.724
#> 12 lm.fit(x = m[, c(2:ncol…   1e7     1.5s     1.5s     0.669    1.71GB    1.34


# formula <- as.formula(y~x+z)
# 
# 
# results <- bench::press(
#   rows = n,
#   {
#     dat <- data.frame(x = rnorm(rows), 
#                       y = rnorm(rows),
#                       z = rnorm(rows))
#     bench::mark(
#       hrec = recipe(formula = formula, data = dat) |>
#         step_intercept() |>
#         step_nls(formula = as.formula(y~.)) |>
#         prep() |>
#         bake(),
#       check = FALSE,
#       relative = FALSE
#     )
#   }
# )

step_nls


n0 <- 5e5
n <- 2e4
n2 <- 1e4
b <- cumsum(rnorm(n0))
b <- b - mean(b)
max_t <- 720 * ceiling(2.554)
a <- hydrorecipes:::convolve_overlap_save(x = b,
                                          y = hydrorecipes:::gamma_3(0:max_t, 0.816, 9.221, 2.554),
                                          0)

max_t <- 720 * ceiling(2.554)

dat <- data.frame(a = a, b = b)
formula <- formula(a~b)

# for gsl_nls
f <- function(z, x) {
  max_t <- 720 * ceiling(z[3])
  hydrorecipes:::convolve_overlap_save(x = x,
                                       y = hydrorecipes:::gamma_3(0:max_t, z[1], z[2], z[3]),
                                       align = 0)[-(1:7200)]
}


results <- bench::mark(
  gsl_fun <- unname(round(coef(gsl_nls(
    fn = f,                   ## model function      
    y = a[-(1:7200)],           ## response vector 
    x = b,
    start = c(A = 0.5, n = 2.0, a = 2.0),  ## starting values
    lower = c(A = 0.01, n = 1.0, a = 1.0), 
    upper = c(A = 1.0, n = 10.0, a = 10.0),
    control = gsl_nls_control(xtol = 1e-8),
    trace = FALSE,
    algorithm = "lm"               ## algorithm
  )), 3)), 
  h_1 = {h = recipe(formula = formula, data = dat) |>
    step_convolve_gamma(b, amplitude = 0.5, k = 2.0, theta = 2.0, 
                        varying = list(name = c("amplitude","k", "theta"),
                                       start = c(0.5, 2.0, 2.0),
                                       lower = c(0.01, 1.0, 1.0),
                                       upper = c(1.0, 10.0, 10.0))) |>
    step_nls(formula = formula(a~b), n_subset = 1L, 
             trace = FALSE,
             algorithm = "lm",
             control = gsl_nls_control(xtol = 1e-8))
  
  h$prep()$bake()
  unname(round(coef(h$steps[[3]]$fit), 3))},
  
  h_10 = {h = recipe(formula = formula, data = dat) |>
    step_convolve_gamma(b, amplitude = 0.5, k = 2.0, theta = 2.0, 
                        varying = list(name = c("amplitude","k", "theta"),
                                       start = c(0.5, 2.0, 2.0),
                                       lower = c(0.01, 1.0, 1.0),
                                       upper = c(1.0, 10.0, 10.0))) |>
    step_nls(formula = formula(a~b), n_subset = 10L, 
             trace = FALSE,
             algorithm = "lm",
             control = gsl_nls_control(xtol = 1e-8))
  
  h$prep()$bake()
  unname(round(coef(h$steps[[3]]$fit), 3))},
  
  h_100 = {h = recipe(formula = formula, data = dat) |>
    step_convolve_gamma(b, amplitude = 0.5, k = 2.0, theta = 2.0, 
                        varying = list(name = c("amplitude","k", "theta"),
                                       start = c(0.5, 2.0, 2.0),
                                       lower = c(0.01, 1.0, 1.0),
                                       upper = c(1.0, 10.0, 10.0))) |>
    step_nls(formula = formula(a~b), n_subset = 100L, 
             trace = FALSE,
             algorithm = "lm",
             control = gsl_nls_control(xtol = 1e-8))
  
  h$prep()$bake()
  unname(round(coef(h$steps[[3]]$fit), 3))},
  
  check = TRUE
)

results
#> # A tibble: 4 × 6
#>   expression                             min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                           <bch> <bch:>     <dbl> <bch:byt>    <dbl>
#> 1 gsl_fun <- unname(round(coef(gsl_nl…  1.7s   1.7s     0.587    1.05GB    0.587
#> 2 h_1                                  2.03s  2.03s     0.494    1.06GB    0    
#> 3 h_10                                 1.09s  1.09s     0.921  377.16MB    0    
#> 4 h_100                                1.04s  1.04s     0.960  322.35MB    0

step_ols_gap_fill

set.seed(123)
n <- 100000
frm <- formula(x ~ y + z)


x <- cumsum(rnorm(n))
dat <- data.table(x = x, y = x, z = as.numeric(1:n))
dat[, x := x + c(rep(20, n/2), rep(0, n/2))]
dat[, x := x + 3.0 * sin(z * 1/n)]
tmp <- copy(dat$x)

# Set value to NA.  These values will be estimated.
dat[60000:70000, x := NA_real_]

dat <- unclass(dat)

bench::mark(
  {h = recipe(formula = frm, data = dat) |>
    step_find_interval(z, vec = c(0, n/2, n)) |>
    step_intercept() |>
    step_spline_b(z, df = 4) |>
    step_drop_columns(z)
  
  hrec = recipe(formula = frm, data = dat) |>
    step_ols_gap_fill(c(x, y, z), recipe = h) |>
    prep() |>
    bake()},
  check = FALSE
)
#> # A tibble: 1 × 6
#>   expression                             min median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                          <bch:> <bch:>     <dbl> <bch:byt>    <dbl>
#> 1 { h = step_drop_columns(step_splin… 8.62ms 8.71ms      115.    9.41MB     2.25

check

step_check_spacing

formula <- as.formula(y~x)

results <- bench::press(
  rows = n,
  {
    dat <- data.frame(x = rnorm(rows),
                      y = 1:rows)
    dat[9:50, "x"] <- NA
    dat[9L, "y"] <- NA
    
    bench::mark(
      hrec1 = recipe(formula = formula, data = dat) |>
        step_check_spacing(y) |>
        step_check_na(y) |>
        prep() |>
        bake(),
      hrec2 =recipe(formula = formula, data = dat) |>
        step_check_spacing(x) |>
        step_check_na(x) |>
        prep() |>
        bake(),
      check = FALSE,
      relative = FALSE,
      min_iterations = 2
    )
  }
)
#> Running with:
#>     rows
#> 1 100000

results
#> # A tibble: 2 × 7
#>   expression   rows      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>  <dbl> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 hrec1      100000    3.2ms   3.27ms      304.    3.39MB        0
#> 2 hrec2      100000   3.22ms   3.29ms      303.    2.29MB        0
sessionInfo()
#> R version 4.6.0 (2026-04-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#>  [1] splines2_0.5.4     RcppRoll_0.3.2     tibble_3.3.1       bench_1.1.4       
#>  [5] data.table_1.18.4  gslnls_1.4.2       collapse_2.1.7     hydrorecipes_0.0.6
#>  [9] Bessel_0.7-0       rmarkdown_2.31    
#> 
#> loaded via a namespace (and not attached):
#>  [1] gtable_0.3.6        xfun_0.59           bslib_0.11.0       
#>  [4] ggplot2_4.0.3       htmlwidgets_1.6.4   recipes_1.3.3      
#>  [7] lattice_0.22-9      vctrs_0.7.3         tools_4.6.0        
#> [10] generics_0.1.4      parallel_4.6.0      pkgconfig_2.0.3    
#> [13] Matrix_1.7-5        RColorBrewer_1.1-3  S7_0.2.2           
#> [16] lifecycle_1.0.5     compiler_4.6.0      farver_2.1.2       
#> [19] codetools_0.2-20    RcppThread_2.4.0    htmltools_0.5.9    
#> [22] sys_3.4.3           buildtools_1.0.0    class_7.3-23       
#> [25] sass_0.4.10         yaml_2.3.12         lazyeval_0.2.3     
#> [28] gmp_0.7-5.1         profmem_0.7.0       prodlim_2026.03.11 
#> [31] plotly_4.12.0       pillar_1.11.1       jquerylib_0.1.4    
#> [34] tidyr_1.3.2         MASS_7.3-65         cachem_1.1.0       
#> [37] gower_1.0.2         rpart_4.1.27        parallelly_1.47.0  
#> [40] lava_1.9.1          tidyselect_1.2.1    digest_0.6.39      
#> [43] future_1.70.0       earthtide_0.1.8     listenv_0.10.1     
#> [46] dplyr_1.2.1         purrr_1.2.2         maketools_1.3.2    
#> [49] splines_4.6.0       fastmap_1.2.0       grid_4.6.0         
#> [52] cli_3.6.6           magrittr_2.0.5      utf8_1.2.6         
#> [55] survival_3.8-6      future.apply_1.20.2 withr_3.0.3        
#> [58] Rmpfr_1.1-2         scales_1.4.0        timechange_0.4.0   
#> [61] lubridate_1.9.5     httr_1.4.8          globals_0.19.1     
#> [64] otel_0.2.0          nnet_7.3-20         timeDate_4052.112  
#> [67] evaluate_1.0.5      knitr_1.51          hardhat_1.4.3      
#> [70] viridisLite_0.4.3   rlang_1.2.0         Rcpp_1.1.1-1.1     
#> [73] glue_1.8.1          sparsevctrs_0.3.6   ipred_0.9-15       
#> [76] jsonlite_2.0.0      R6_2.6.1