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         5.95      1        1.64
#> 2 hrec2          100  1      1.00      5.93      1        1.50
#> 3 rec            100  6.08   5.91      1     24681.       1   
#> 4 hrec1        10000  1.00   1.00      5.80      1        1   
#> 5 hrec2        10000  1      1         5.79      1        1.52
#> 6 rec          10000  6.04   5.77      1         3.23     1.01
#> 7 hrec1      5000000  1      1.01      5.69      1        1.32
#> 8 hrec2      5000000  1.00   1         5.73      1        1.32
#> 9 rec        5000000  6.03   5.75      1         3.23     1

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.03     55.9      1   
#> 2 hrec2          100  1.04   1.03      3.91      1        1.52
#> 3 rec            100  4.19   4.01      1        16.3      1.00
#> 4 hrec1        10000  1      1         4.07      1        1.51
#> 5 hrec2        10000  1.03   1.04      3.93      1        1.51
#> 6 rec          10000  4.18   4.05      1         1.03     1   
#> 7 hrec1      5000000  1      1         4.14      1        1.52
#> 8 hrec2      5000000  1.04   1.04      3.98      1        1   
#> 9 rec        5000000  4.19   4.10      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      1         63.1       Inf     1.44
#> 2 prep(hrec2)            100  1.00   1.01      64.1       NaN     1.91
#> 3 recipes::prep(rec)     100 66.9   65.8        1         Inf     1   
#> 4 hrec1$prep()         10000  1      1         65.2       NaN     1.46
#> 5 prep(hrec2)          10000  1.01   1.01      64.8       NaN     1.47
#> 6 recipes::prep(rec)   10000 67.0   66.2        1         Inf     1   
#> 7 hrec1$prep()       5000000  1      1         23.1       NaN   NaN   
#> 8 prep(hrec2)        5000000  1.01   1.01      23.0       NaN   Inf   
#> 9 recipes::prep(rec) 5000000 23.8   23.2        1         Inf   NaN

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      1         58.0     40.9      1.46
#> 2 bake(prep(hrec2))                1e2  1.01   1.00      60.6      1        1.46
#> 3 recipes::bake(recipes::prep(r…   1e2 63.6   61.8        1      198.       1   
#> 4 hrec1$prep()$bake()              1e4  1      1         63.8      1        1.44
#> 5 bake(prep(hrec2))                1e4  1.01   1.01      63.1      1        1.44
#> 6 recipes::bake(recipes::prep(r…   1e4 65.4   64.8        1        2.85     1   
#> 7 hrec1$prep()$bake()              5e6  1      1         22.3      1      Inf   
#> 8 bake(prep(hrec2))                5e6  1.02   1.01      22.1      1      NaN   
#> 9 recipes::bake(recipes::prep(r…   5e6 23.1   22.3        1        2.50   Inf

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        14.1       1        1.46
#> 2 rec            100 14.3   14.1       1         5.81     1   
#> 3 hrec         10000  1      1        14.6       1        1.45
#> 4 rec          10000 14.6   14.6       1         2.72     1   
#> 5 hrec       5000000  1      1         6.43      1      Inf   
#> 6 rec        5000000  6.95   6.41      1         2.50   NaN

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        13.9       2.33     1   
#> 2 rec            100 14.2   13.9       1         1        1.65
#> 3 hrec         10000  1      1        13.1       1        1   
#> 4 rec          10000 13.4   13.2       1         2.25     1.05
#> 5 hrec       5000000  1      1         1.89      1      NaN   
#> 6 rec        5000000  1.86   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        14.2       1        1.44
#> 2 rec            100 14.6   14.3       1         5.23     1   
#> 3 hrec         10000  1      1        14.2       1        1.43
#> 4 rec          10000 14.5   14.3       1         1.32     1   
#> 5 hrec       5000000  1      1         4.25      1        2.08
#> 6 rec        5000000  4.53   4.21      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        13.7      53.8      1.45
#> 2 hrec2          100  1.35   1.34     10.2       1        1.44
#> 3 rec            100 13.9   13.7       1         7.92     1   
#> 4 hrec1        10000  1      1        11.7       1        1.00
#> 5 hrec2        10000  1.30   1.29      9.09      1.00     1   
#> 6 rec          10000 12.1   11.8       1         1.39     1.70
#> 7 hrec1      5000000  1.07   1.03      1.69      1      Inf   
#> 8 hrec2      5000000  1      1         1.74      1.00   NaN   
#> 9 rec        5000000  1.80   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        14.4       1       1.45
#> 2 rec            100  14.5   14.4       1        46.6     1   
#> 3 hrec         10000   1      1        13.9       1       1   
#> 4 rec          10000  14.5   14.3       1        51.5     1.65
#> 5 hrec       5000000   1      1        23.0       1       1   
#> 6 rec        5000000  23.2   23.2       1     14557.      1.09

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   6.85ms   12.2ms     92.6     34.9MB     2.10
#> 2 rec         1000000  25.82ms     33ms     32.1     34.4MB     2.14
#> 3 hrec1      10000000  54.67ms   73.8ms     14.5    343.3MB     3.61
#> 4 rec        10000000 102.56ms    103ms      9.70   343.4MB     2.42

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   4.65ms   7.98ms     141.       12MB     2.07
#> 2 rec         1000000  31.93ms  38.87ms      27.0    30.7MB     2.08
#> 3 base        1000000   7.79ms   8.37ms     102.     19.1MB     0   
#> 4 hrec1      10000000   7.84ms   8.36ms     117.     11.4MB     0   
#> 5 rec        10000000  53.34ms  54.49ms      18.4    64.9MB     2.04
#> 6 base       10000000  10.59ms  11.01ms      90.7    19.1MB     2.16

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.63ms   1.7ms     585.    860.8KB     4.10
#> 2 rec                           1e6 21.65ms 21.99ms      45.3    8.31MB     4.32
#> 3 h <- { hrec1 = bake(prep(s…   1e7  1.95ms  1.99ms     501.   315.12KB     4.11
#> 4 rec                           1e7 43.88ms  44.6ms      22.2   76.89MB     2.02

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.36ms    1.4ms    708.     556.8KB     4.10
#> 2 hrec1        10000   2.07ms    2.1ms    472.      18.1KB     4.39
#> 3 hrec1      5000000 495.65ms  495.7ms      2.02    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… 31.02ms 31.41ms    31.8      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        16.0       1        1   
#> 2 rec            100 16.1   16.0       1         3.44     1.67
#> 3 hrec1        10000  1      1        11.6       1        1   
#> 4 rec          10000 11.8   11.6       1         2.54     1.05
#> 5 hrec1      5000000  1      1         3.95      1        1.32
#> 6 rec        5000000  4.44   3.95      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  66.08ms  67.52ms    14.9      18.6MB    0    
#> 2 hrec        5000000 518.57ms 518.57ms     1.93    155.9MB    0    
#> 3 hrec       10000000    1.08s    1.08s     0.927   308.5MB    0.927

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        13.7       1        1.27
#> 2 rec            100 14.2   13.6       1        11.1      1   
#> 3 hrec         10000  1      1         7.75      1        1   
#> 4 rec          10000  7.73   7.77      1         3.47     1.05
#> 5 hrec       5000000  1      1         1.10      1      NaN   
#> 6 rec        5000000  1.10   1.10      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.03   1.02     15.1      13.5      1.51   301     3
#>  2 hrec2          100  1.02   1.02     15.1       1        1      303     2
#>  3 hrec3          100  1      1.00     15.4       1.20     1.53   304     3
#>  4 hrec4          100  1.00   1        15.4       1        1.00   309     2
#>  5 rec1           100 15.4   15.4       1        13.6      1.05    19     2
#>  6 rec2           100 15.2   15.1       1.03      5.80     1.71    18     3
#>  7 rec3           100 15.0   14.7       1.05      3.10     1.11    19     2
#>  8 rec4           100 14.8   14.6       1.06      2.75     1.06    20     2
#>  9 hrec1        10000  1.63   1.69      7.17      1.22   Inf       80     1
#> 10 hrec2        10000  2.16   2.14      6.40      1      NaN       75     0
#> 11 hrec3        10000  1.03   1.03     11.3       1.22   Inf      129     1
#> 12 hrec4        10000  1      1        13.3       1      Inf      149     2
#> 13 rec1         10000 13.8   13.7       1         6.01   Inf       11     1
#> 14 rec2         10000 13.3   13.1       1.04      5.69   Inf       11     1
#> 15 rec3         10000 11.6   11.3       1.20      2.24   Inf       12     2
#> 16 rec4         10000 11.3   11.1       1.23      1.91   Inf       14     1
#> 17 hrec1      5000000  2.17   2.17      3.59      1.22     1        1     1
#> 18 hrec2      5000000  1.80   1.80      4.32      1        1.21     1     1
#> 19 hrec3      5000000  1      1         7.78      1.22     2.17     1     1
#> 20 hrec4      5000000  1.09   1.09      7.14      1        1.99     1     1
#> 21 rec1       5000000  7.58   7.58      1.03      6.01     1.43     1     5
#> 22 rec2       5000000  7.78   7.78      1         5.68     1.39     1     5
#> 23 rec3       5000000  3.04   3.04      2.56      2.23     1.43     1     2
#> 24 rec4       5000000  2.86   2.86      2.72      1.90     1.52     1     2
#> # ℹ 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        15.1      1.01     1.43
#> 2 rec            100  14.7   15.1       1        1        1   
#> 3 hrec         10000   1      1        21.0      1        1   
#> 4 rec          10000  20.9   21.0       1       17.8      1.13
#> 5 hrec       5000000   1      1       136.       1      NaN   
#> 6 rec        5000000 138.   136.        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        15.0       3.23     1.21
#> 2 rec            100 14.6   15.0       1         1        1   
#> 3 hrec         10000  1      1        13.3       1        2.15
#> 4 rec          10000 13.4   13.4       1         2.65     1   
#> 5 hrec       5000000  1      1         3.18      1      NaN   
#> 6 rec        5000000  3.20   3.18      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        15.5      6.69     2.19
#> 2 rec            100  15.6   15.6       1        1        1   
#> 3 hrec         10000   1      1        15.7      1        2.15
#> 4 rec          10000  15.9   15.7       1       32.7      1   
#> 5 hrec       5000000   1      1        77.5      1      NaN   
#> 6 rec        5000000  78.7   77.8       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       132.      1.81     1   
#> 2 { rec = recipes::bake(recipes…   2e4  135.   133.        1       1        1.50
#> 3 hrec                             2e5    1      1       826.      1      NaN   
#> 4 { rec = recipes::bake(recipes…   2e5  852.   834.        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.84ms    1.9ms     524.    723.4KB     5.08
#> 2 hrec       2000000  27.29ms   28.1ms      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.4       1         NaN
#> 2 rec            100 15.5   15.7       1         5.76      Inf
#> 3 hrec         10000  1      1        11.4       1         Inf
#> 4 rec          10000 11.5   11.4       1         2.67      NaN
#> 5 hrec       5000000  1      1         1.61      1         NaN
#> 6 rec        5000000  1.61   1.61      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        14.5       1      NaN   
#> 2 rec            100 14.6   14.4       1        18.9    Inf   
#> 3 hrec         10000  1      1         8.76      1      NaN   
#> 4 rec          10000  8.82   8.81      1         4.64   NaN   
#> 5 hrec       5000000  1      1         2.61      1        1.30
#> 6 rec        5000000  2.58   2.61      1         4.62     1

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.3       2.98      NaN
#> 2 rec            100 13.4   13.2       1         1         Inf
#> 3 hrec         10000  1      1         8.35      1         NaN
#> 4 rec          10000  8.35   8.33      1         4.49      NaN
#> 5 hrec       5000000  1      1         3.39      1         NaN
#> 6 rec        5000000  3.43   3.39      1         4.47      Inf

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.26ms   1.33ms    748.     553.6KB     0   
#> 2 hrec1        10000   1.67ms   1.72ms    581.     160.5KB     3.00
#> 3 hrec1      5000000  187.5ms 187.71ms      5.33    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
#> 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
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 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.46ms   1.51ms    661.      5.91KB     0   
#> 2 hrec2          100   1.54ms   1.61ms    621.    541.13KB     2.07
#> 3 hrec1        10000   2.35ms   2.38ms    419.    160.59KB     0   
#> 4 hrec2        10000   2.46ms   2.52ms    396.     83.62KB     0   
#> 5 hrec1      5000000 546.89ms 546.89ms      1.83    76.3MB     0   
#> 6 hrec2      5000000  566.2ms  566.2ms      1.77   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
#> 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
#> 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.81ms   1.85ms    536.        53KB     2.07
#> 2 hrec2          100   1.89ms   1.95ms    508.      28.2KB     2.07
#> 3 hrec1        10000   2.69ms   2.73ms    365.     182.6KB     0   
#> 4 hrec2        10000   2.81ms   2.86ms    349.     105.6KB     0   
#> 5 hrec1      5000000 545.79ms 545.79ms      1.83    76.3MB     0   
#> 6 hrec2      5000000 556.32ms 556.32ms      1.80    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
#> 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
#> 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.84ms   542.       30.4KB     2.08
#> 2 hrec2          100    1.9ms   1.95ms   513.       28.2KB     2.08
#> 3 hrec1        10000   3.54ms    3.6ms   276.      417.1KB     0   
#> 4 hrec2        10000   2.79ms   2.83ms   353.      105.6KB     0   
#> 5 hrec1      5000000    1.26s    1.26s     0.793   190.8MB     0   
#> 6 hrec2      5000000 565.35ms 565.35ms     1.77     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
#> 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
#> 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        51.8      1.94      Inf
#> 2 hrec3        10000  52.9   52.0       1        1         NaN
#> 3 hrec1       100000   1      1        95.1      1.99      NaN
#> 4 hrec3       100000 102.   101.        1        1         NaN
#> 5 hrec1      1000000   1      1        90.2      2.00      NaN
#> 6 hrec3      1000000  91.8   89.9       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
#> 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
#> 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
#> 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   9.06ms   9.11ms    110.     41.98KB     0   
#> 2 hrec2        1000   2.01ms   2.05ms    487.     43.12KB     0   
#> 3 hrec1       10000  61.34ms  61.48ms     16.2   182.61KB     2.32
#> 4 hrec2       10000   2.77ms   2.81ms    355.    183.75KB     0   
#> 5 hrec1      100000 548.88ms 548.88ms      1.82    1.55MB     0   
#> 6 hrec2      100000   10.1ms  10.33ms     96.1     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.28ms   1.32ms    753.     557.8KB     2.08
#> 2 hrec1        10000   1.46ms    1.5ms    666.     160.5KB     0   
#> 3 hrec1      5000000 178.22ms 178.47ms      5.60    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.37ms   1.42ms   705.        572KB     2.08
#> 2 hrec1        10000   5.21ms   5.25ms   190.        786KB     0   
#> 3 hrec1      5000000    1.54s    1.54s     0.649     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.78ms   1.83ms      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     10ms      99.3     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.65ms   1.72ms    580.    588.65KB     0   
#> 2 hrec2          100   1.65ms   1.72ms    582.     17.76KB     0   
#> 3 hrec3          100   1.42ms   1.46ms    674.    567.22KB     2.79
#> 4 hrec1        10000   2.22ms   2.27ms    435.      1.45MB     0   
#> 5 hrec2        10000   2.15ms   2.31ms    434.      1.15MB     0   
#> 6 hrec3        10000   2.63ms   2.67ms    374.    268.44KB     0   
#> 7 hrec1      5000000 695.73ms 695.73ms      1.44   724.8MB     1.44
#> 8 hrec2      5000000 365.86ms  379.4ms      2.64  572.21MB     0   
#> 9 hrec3      5000000 433.12ms 438.18ms      2.28   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  18.36ms  18.62ms    52.9      6.11MB    0    
#> 2 hrec2                       1e5   9.89ms  10.61ms    94.5      2.06MB    0    
#> 3 hrec3 <- bake(prep(step_…   1e5   7.07ms   7.42ms   131.       1.92MB    0    
#> 4 hrec1                       1e6 172.88ms  174.1ms     5.74    61.04MB    0    
#> 5 hrec2                       1e6  87.31ms  88.82ms    11.2      20.6MB    0    
#> 6 hrec3 <- bake(prep(step_…   1e6  56.93ms  59.44ms    16.8     19.09MB    0    
#> 7 hrec1                       1e7    2.43s    2.43s     0.411  610.35MB    0.411
#> 8 hrec2                       1e7    1.02s    1.02s     0.977     206MB    0    
#> 9 hrec3 <- bake(prep(step_…   1e7  881.6ms  881.6ms     1.13   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   6.95ms  10.93ms    98.7     16.79MB    2.90 
#>  2 hrec2                      1e5   7.71ms   7.93ms   112.      19.08MB    0    
#>  3 lm                         1e5  13.65ms  17.43ms    54.4     24.62MB    3.20 
#>  4 lm.fit(x = m[, c(2:ncol…   1e5  13.05ms  13.31ms    75.0     17.55MB    0    
#>  5 hrec1                      1e6  55.46ms  62.46ms    15.3    167.85MB    0    
#>  6 hrec2                      1e6  64.17ms  82.52ms    12.7    190.74MB    3.18 
#>  7 lm                         1e6 126.13ms 165.12ms     6.40   244.14MB    0    
#>  8 lm.fit(x = m[, c(2:ncol…   1e6 140.62ms 150.81ms     6.73   175.48MB    0    
#>  9 hrec1                      1e7 798.86ms 798.86ms     1.25     1.64GB    1.25 
#> 10 hrec2                      1e7    1.02s    1.02s     0.976    1.86GB    0.976
#> 11 lm                         1e7    1.87s    1.87s     0.535    2.38GB    1.07 
#> 12 lm.fit(x = m[, c(2:ncol…   1e7    1.52s    1.52s     0.656    1.71GB    0.656


# 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:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 gsl_fun <- unname(round(coef(g…    1.45s    1.45s     0.690     839MB    0    
#> 2 h_1                                1.77s    1.77s     0.565     847MB    0.565
#> 3 h_10                            818.68ms 818.68ms     1.22      290MB    0    
#> 4 h_100                            723.4ms  723.4ms     1.38      234MB    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.28ms 8.35ms      119.    9.41MB        0

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.19ms   3.26ms      306.    3.39MB        0
#> 2 hrec2      100000   3.18ms   3.26ms      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.57           bslib_0.11.0       
#>  [4] ggplot2_4.0.3       htmlwidgets_1.6.4   recipes_1.3.2      
#>  [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.3.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.2        
#> [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