Benchmarking
benchmarking.Rmd
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 1.02 5.54 539. 2.03
#> 2 hrec2 100 1.00 1 5.79 1 2.02
#> 3 rec 100 5.97 5.77 1 4852. 1
#> 4 hrec1 10000 1.01 1.00 5.81 1 1.00
#> 5 hrec2 10000 1 1 5.82 1 1
#> 6 rec 10000 5.97 5.75 1 5.07 1.01
#> 7 hrec1 5000000 1 1 5.72 1 1
#> 8 hrec2 5000000 1.01 1.00 5.78 1 2.02
#> 9 rec 5000000 6.00 5.77 1 5.07 2.03
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 3.96 55.9 1.00
#> 2 hrec2 100 1.04 1.03 3.88 1 1
#> 3 rec 100 4.11 3.97 1 16.4 1.00
#> 4 hrec1 10000 1 1 3.95 1 2.03
#> 5 hrec2 10000 1.03 1.03 3.86 1 1
#> 6 rec 10000 4.13 3.98 1 1.51 2.04
#> 7 hrec1 5000000 1 1 3.95 1 1
#> 8 hrec2 5000000 1.03 1.02 3.87 1 2.02
#> 9 rec 5000000 4.11 3.97 1 1.51 2.03
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.6 53.8 1.17
#> 2 prep(hrec2) 100 1.00 1.00 64.3 1 1.17
#> 3 recipes::prep(rec) 100 66.3 66.3 1 1528. 1
#> 4 hrec1$prep() 10000 1.01 1 63.1 NaN 1.00
#> 5 prep(hrec2) 10000 1 1.00 63.3 NaN 1
#> 6 recipes::prep(rec) 10000 66.0 63.7 1 Inf 1.06
#> 7 hrec1$prep() 5000000 1 1.03 75.7 NaN NaN
#> 8 prep(hrec2) 5000000 1.02 1 77.7 NaN NaN
#> 9 recipes::prep(rec) 5000000 27.6 103. 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 1.01 59.3 47.6 1.00
#> 2 bake(prep(hrec2)) 1e2 1.00 1 62.0 1 1
#> 3 recipes::bake(recipes::prep(r… 1e2 62.3 62.9 1 48.0 1.06
#> 4 hrec1$prep()$bake() 1e4 1 1 59.8 1 1.99
#> 5 bake(prep(hrec2)) 1e4 1.01 1.00 60.0 1 1.98
#> 6 recipes::bake(recipes::prep(r… 1e4 62.9 60.3 1 2.94 1
#> 7 hrec1$prep()$bake() 5e6 1.02 1.01 54.7 1 NaN
#> 8 bake(prep(hrec2)) 5e6 1 1 54.9 1 NaN
#> 9 recipes::bake(recipes::prep(r… 5e6 24.9 25.4 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.3 5.17 2.00
#> 2 rec 100 14.3 14.2 1 1 1
#> 3 hrec 10000 1 1 14.9 1 1.99
#> 4 rec 10000 14.6 14.7 1 2.82 1
#> 5 hrec 5000000 1 1 5.67 1 1
#> 6 rec 5000000 5.88 5.70 1 2.50 1.36
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 14.1 2.30 1.97
#> 2 rec 100 14.1 13.9 1 1 1
#> 3 hrec 10000 1 1 14.3 1 2.02
#> 4 rec 10000 13.7 14.3 1 2.35 1
#> 5 hrec 5000000 1 1 1.96 1 1
#> 6 rec 5000000 2.06 1.94 1 2.00 5.10
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 5.75 2.00
#> 2 rec 100 14.7 14.2 1 1 1
#> 3 hrec 10000 1 1 15.0 1 2.91
#> 4 rec 10000 15.1 15.2 1 1.41 1
#> 5 hrec 5000000 1 1 4.01 1 2.99
#> 6 rec 5000000 4.02 4.01 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 2.03
#> 2 hrec2 100 1.35 1.33 10.3 1 1
#> 3 rec 100 13.9 13.7 1 8.72 2.17
#> 4 hrec1 10000 1 1 11.9 1 1.74
#> 5 hrec2 10000 1.31 1.29 9.16 1.00 1
#> 6 rec 10000 11.9 12.3 1 1.41 2.17
#> 7 hrec1 5000000 1 1 1.22 1 3.11
#> 8 hrec2 5000000 1.03 1.59 1.05 1.00 1
#> 9 rec 5000000 1.76 1.66 1 1.33 1.91
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.8 7.59 2.03
#> 2 rec 100 14.7 15.0 1 1 1
#> 3 hrec 10000 1 1 15.2 1 1
#> 4 rec 10000 14.7 15.2 1 57.6 1.10
#> 5 hrec 5000000 1 1 24.6 1 1
#> 6 rec 5000000 25.3 24.8 1 14563. 2.16
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 14.7ms 14.9ms 60.7 34.9MB 7.59
#> 2 rec 1000000 29.2ms 34.1ms 30.2 34.5MB 2.16
#> 3 hrec1 10000000 156.7ms 156.7ms 6.38 343.3MB 31.9
#> 4 rec 10000000 112.7ms 112.7ms 8.87 343.4MB 26.6
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.52ms 7.38ms 122. 12MB 2.08
#> 2 rec 1000000 34.66ms 35.58ms 28.1 30.7MB 2.16
#> 3 base 1000000 8.65ms 9.42ms 107. 19.1MB 6.54
#> 4 hrec1 10000000 10.87ms 13.22ms 76.5 11.4MB 2.07
#> 5 rec 10000000 59.91ms 70.06ms 14.7 64.9MB 2.10
#> 6 base 10000000 13.15ms 13.94ms 64.6 19.1MB 2.08
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.8ms 554. 860.8KB 2.03
#> 2 rec 1e6 22.93ms 23.81ms 41.7 8.44MB 2.09
#> 3 h <- { hrec1 = bake(prep(s… 1e7 2ms 2.05ms 486. 315.12KB 2.57
#> 4 rec 1e7 49.97ms 53.55ms 18.7 76.9MB 0
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.39ms 1.43ms 689. 559.2KB 4.11
#> 2 hrec1 10000 2.11ms 2.15ms 464. 18.1KB 2.02
#> 3 hrec1 5000000 559.94ms 559.94ms 1.79 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… 32.42ms 32.94ms 30.4 15.7KB 0
#> 2 ccf_base <- as.numeric(ccf(x, y,… 1.95s 1.95s 0.514 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 8.81 2.30 1.97
#> 2 rec 100 8.61 8.85 1 1 1
#> 3 hrec1 10000 1 1 7.69 1 1
#> 4 rec 10000 7.47 7.72 1 2.55 1.05
#> 5 hrec1 5000000 1 1 1.89 1 1.89
#> 6 rec 5000000 1.89 1.89 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 73.5ms 75.4ms 12.5 19.1MB 0
#> 2 hrec 5000000 500ms 500ms 2.00 155.9MB 0
#> 3 hrec 10000000 956.3ms 956.3ms 1.05 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 14.0 3.27 2.04
#> 2 rec 100 14.2 14.0 1 1 1
#> 3 hrec 10000 1 1 8.06 1 1
#> 4 rec 10000 7.84 8.01 1 3.48 2.19
#> 5 hrec 5000000 1 1 1.14 1 Inf
#> 6 rec 5000000 1.14 1.14 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.04 1.03 14.8 15.5 1 296 1
#> 2 hrec2 100 1.03 1.02 15.0 1 2.03 294 2
#> 3 hrec3 100 1.01 1.00 15.2 1.20 2.03 299 2
#> 4 hrec4 100 1 1 15.3 1 2.03 300 2
#> 5 rec1 100 15.0 15.4 1 14.0 1.05 19 1
#> 6 rec2 100 14.6 14.7 1.04 6.03 2.18 19 2
#> 7 rec3 100 14.6 14.4 1.05 3.34 2.20 19 2
#> 8 rec4 100 14.9 15.0 1.02 2.99 1.02 20 1
#> 9 hrec1 10000 1.57 1.55 8.72 1.22 NaN 93 0
#> 10 hrec2 10000 1.56 1.55 8.68 1 Inf 88 1
#> 11 hrec3 10000 1.02 1.59 10.0 1.22 Inf 99 1
#> 12 hrec4 10000 1 1 13.1 1 NaN 140 0
#> 13 rec1 10000 13.9 13.8 1 6.02 Inf 10 1
#> 14 rec2 10000 13.2 12.9 1.11 5.69 Inf 11 1
#> 15 rec3 10000 11.2 11.0 1.31 2.24 Inf 13 1
#> 16 rec4 10000 10.9 10.6 1.35 1.92 Inf 14 1
#> 17 hrec1 5000000 1.75 1.75 4.78 1.22 1 1 1
#> 18 hrec2 5000000 1.68 1.68 4.96 1 1.04 1 1
#> 19 hrec3 5000000 1.47 1.47 5.68 1.22 3.57 1 3
#> 20 hrec4 5000000 1 1 8.34 1.00 1.75 1 1
#> 21 rec1 5000000 8.34 8.34 1 6.01 1.88 1 9
#> 22 rec2 5000000 8.31 8.31 1.00 5.68 2.73 1 13
#> 23 rec3 5000000 3.77 3.77 2.21 2.23 1.39 1 3
#> 24 rec4 5000000 2.94 2.94 2.83 1.90 1.19 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 8.20 1 1.97
#> 2 rec 100 8.16 8.10 1 1.41 1
#> 3 hrec 10000 1 1 11.5 1 1.95
#> 4 rec 10000 11.2 11.6 1 17.8 1
#> 5 hrec 5000000 1 1 163. 1 5.45
#> 6 rec 5000000 188. 183. 1 13.1 1
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 14.7 3.15 1
#> 2 rec 100 15.0 14.7 1 1 1.00
#> 3 hrec 10000 1 1 13.4 1 1
#> 4 rec 10000 13.1 13.4 1 2.71 1.02
#> 5 hrec 5000000 1 1 2.71 1 NaN
#> 6 rec 5000000 2.72 2.71 1 2.50 Inf
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.7 6.03 1
#> 2 rec 100 14.9 14.7 1 1 1.05
#> 3 hrec 10000 1 1 14.9 1 1
#> 4 rec 10000 15.1 14.8 1 32.9 1.03
#> 5 hrec 5000000 1 1 77.7 1 NaN
#> 6 rec 5000000 79.9 78.0 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 78.1 1.78 NaN
#> 2 { rec = recipes::bake(recipes… 2e4 80.6 78.5 1 1 Inf
#> 3 hrec 2e5 1 1 560. 1 NaN
#> 4 { rec = recipes::bake(recipes… 2e5 605. 565. 1 1.50 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.99ms 2.05ms 483. 723.4KB 2.21
#> 2 hrec 2000000 29.32ms 29.91ms 33.3 15.3MB 0
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 16.2 1 1
#> 2 rec 100 16.5 16.2 1 6.51 1.02
#> 3 hrec 10000 1 1 11.6 1 1
#> 4 rec 10000 11.6 11.7 1 2.68 1.03
#> 5 hrec 5000000 1 1 1.29 1 1
#> 6 rec 5000000 1.29 1.29 1 2.62 3.11
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 7.65 2.06 NaN
#> 2 rec 100 7.67 7.61 1 1 Inf
#> 3 hrec 10000 1 1 6.35 1 1.00
#> 4 rec 10000 6.37 6.34 1 4.64 1
#> 5 hrec 5000000 1 1 3.54 1 1.77
#> 6 rec 5000000 3.43 3.54 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 8.07 2.85 NaN
#> 2 rec 100 7.84 8.09 1 1 Inf
#> 3 hrec 10000 1 1 6.22 1 Inf
#> 4 rec 10000 6.23 6.27 1 4.50 NaN
#> 5 hrec 5000000 1 1 3.61 1 NaN
#> 6 rec 5000000 3.48 3.61 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.33ms 1.39ms 718. 553.9KB 0
#> 2 hrec1 10000 1.7ms 1.74ms 572. 160.5KB 2.08
#> 3 hrec1 5000000 191.65ms 192.01ms 5.21 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
#> 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
#> 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.49ms 1.56ms 640. 566.5KB 2.22
#> 2 hrec2 100 1.6ms 1.66ms 599. 541.1KB 2.07
#> 3 hrec1 10000 2.42ms 2.46ms 406. 160.6KB 0
#> 4 hrec2 10000 2.5ms 2.56ms 390. 83.6KB 2.08
#> 5 hrec1 5000000 656.74ms 656.74ms 1.52 76.3MB 0
#> 6 hrec2 5000000 663.27ms 663.27ms 1.51 38.2MB 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
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 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.6ms 1.66ms 600. 635.3KB 2.08
#> 2 hrec2 100 1.71ms 1.76ms 565. 7.98KB 2.08
#> 3 hrec1 10000 2.52ms 2.58ms 386. 162.39KB 0
#> 4 hrec2 10000 2.59ms 2.68ms 368. 85.33KB 2.09
#> 5 hrec1 5000000 666.33ms 666.33ms 1.50 76.3MB 0
#> 6 hrec2 5000000 675.67ms 675.67ms 1.48 38.15MB 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
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> a: 0
#> 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
#> 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.64ms 1.68ms 579. 572.59KB 0
#> 2 hrec2 100 1.73ms 1.78ms 558. 7.98KB 2.09
#> 3 hrec1 10000 3.37ms 3.44ms 290. 396.84KB 2.10
#> 4 hrec2 10000 2.61ms 2.67ms 374. 85.33KB 0
#> 5 hrec1 5000000 1.37s 1.37s 0.732 190.74MB 0
#> 6 hrec2 5000000 659.34ms 659.34ms 1.52 38.15MB 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
#> 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
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 48.6 1 Inf
#> 2 hrec3 10000 50.3 49.1 1 4.06 NaN
#> 3 hrec1 100000 1 1 94.2 1.99 NaN
#> 4 hrec3 100000 96.1 95.0 1 1 NaN
#> 5 hrec1 1000000 1 1 81.4 2.00 NaN
#> 6 hrec3 1000000 82.7 82.0 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
#> 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
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.68ms 8.72ms 115. 584.14KB 0
#> 2 hrec2 1000 1.82ms 1.89ms 522. 22.88KB 2.10
#> 3 hrec1 10000 59.09ms 59.26ms 16.9 162.36KB 0
#> 4 hrec2 10000 2.63ms 2.68ms 371. 163.5KB 2.10
#> 5 hrec1 100000 528.35ms 528.35ms 1.89 1.53MB 0
#> 6 hrec2 100000 10.03ms 10.82ms 92.5 1.53MB 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.35ms 1.4ms 710. 557.8KB 2.11
#> 2 hrec1 10000 1.53ms 1.58ms 628. 160.5KB 0
#> 3 hrec1 5000000 182.88ms 183.23ms 5.45 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.46ms 1.49ms 666. 572KB 2.09
#> 2 hrec1 10000 5.22ms 5.26ms 189. 786KB 2.10
#> 3 hrec1 5000000 1.58s 1.58s 0.633 381MB 0.633
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.84ms 1.89ms 527. 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.1ms 97.0 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.74ms 574. 588.65KB 2.88
#> 2 hrec2 100 1.68ms 1.74ms 574. 17.76KB 0
#> 3 hrec3 100 1.49ms 1.55ms 642. 567.22KB 2.91
#> 4 hrec1 10000 2.31ms 2.38ms 420. 1.45MB 0
#> 5 hrec2 10000 2.25ms 2.33ms 428. 1.15MB 2.87
#> 6 hrec3 10000 2.68ms 2.74ms 364. 268.44KB 0
#> 7 hrec1 5000000 488.26ms 488.26ms 2.05 724.8MB 2.05
#> 8 hrec2 5000000 423.21ms 423.21ms 2.36 572.21MB 2.36
#> 9 hrec3 5000000 443.78ms 443.78ms 2.25 129.7MB 2.25
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.07ms 19.49ms 50.9 6.67MB 2.68
#> 2 hrec2 1e5 9.98ms 10.21ms 97.5 2.62MB 0
#> 3 hrec3 <- bake(prep(step_… 1e5 7.1ms 7.51ms 132. 2.49MB 0
#> 4 hrec1 1e6 180.92ms 181.86ms 5.50 61.04MB 0
#> 5 hrec2 1e6 88.89ms 91.5ms 11.0 20.6MB 0
#> 6 hrec3 <- bake(prep(step_… 1e6 62.4ms 64.09ms 15.7 19.09MB 0
#> 7 hrec1 1e7 2.16s 2.16s 0.463 610.35MB 0
#> 8 hrec2 1e7 1.1s 1.1s 0.909 206MB 0.909
#> 9 hrec3 <- bake(prep(step_… 1e7 893.65ms 893.65ms 1.12 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 14.87ms 15.1ms 60.7 17.37MB 0
#> 2 hrec2 1e5 15.99ms 16.24ms 61.4 19.13MB 2.19
#> 3 lm 1e5 23.18ms 32.31ms 31.3 47.75MB 0
#> 4 lm.fit(x = m[, c(2:ncol… 1e5 12.04ms 12.56ms 78.5 17.55MB 2.31
#> 5 hrec1 1e6 144.78ms 162.64ms 6.15 167.85MB 3.07
#> 6 hrec2 1e6 144.47ms 144.93ms 6.90 190.74MB 2.30
#> 7 lm 1e6 162.61ms 176.31ms 5.67 473.4MB 2.84
#> 8 lm.fit(x = m[, c(2:ncol… 1e6 127.19ms 127.2ms 7.58 175.48MB 2.53
#> 9 hrec1 1e7 1.48s 1.48s 0.674 1.64GB 0
#> 10 hrec2 1e7 1.72s 1.72s 0.580 1.86GB 0.580
#> 11 lm 1e7 2.62s 2.62s 0.381 4.67GB 0.381
#> 12 lm.fit(x = m[, c(2:ncol… 1e7 1.37s 1.37s 0.730 1.71GB 1.46
# 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.94s 1.94s 0.515 1.17GB 0
#> 2 h_1 2.42s 2.42s 0.412 1.18GB 0
#> 3 h_10 1.37s 1.37s 0.730 420.96MB 0.730
#> 4 h_100 1.21s 1.21s 0.828 346.48MB 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… 13.8ms 14ms 70.7 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.22ms 3.29ms 300. 3.39MB 0
#> 2 hrec2 100000 3.17ms 3.24ms 308. 2.29MB 2.17
sessionInfo()
#> R version 4.5.0 (2025-04-11)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.2 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=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
#> [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
#> [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
#> [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: 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.1 tibble_3.2.1 bench_1.1.4
#> [5] hydrorecipes_0.0.6 Bessel_0.6-1 data.table_1.17.0 gslnls_1.4.1
#> [9] collapse_2.1.1
#>
#> loaded via a namespace (and not attached):
#> [1] gtable_0.3.6 xfun_0.52 bslib_0.9.0
#> [4] ggplot2_3.5.2 htmlwidgets_1.6.4 recipes_1.3.0
#> [7] lattice_0.22-6 vctrs_0.6.5 tools_4.5.0
#> [10] generics_0.1.3 parallel_4.5.0 pkgconfig_2.0.3
#> [13] Matrix_1.7-3 desc_1.4.3 lifecycle_1.0.4
#> [16] compiler_4.5.0 textshaping_1.0.0 munsell_0.5.1
#> [19] codetools_0.2-20 RcppThread_2.2.0 htmltools_0.5.8.1
#> [22] class_7.3-23 sass_0.4.10 yaml_2.3.10
#> [25] lazyeval_0.2.2 gmp_0.7-5 profmem_0.6.0
#> [28] prodlim_2024.06.25 plotly_4.10.4 pillar_1.10.2
#> [31] pkgdown_2.1.1 jquerylib_0.1.4 tidyr_1.3.1
#> [34] MASS_7.3-65 cachem_1.1.0 gower_1.0.2
#> [37] rpart_4.1.24 parallelly_1.43.0 lava_1.8.1
#> [40] tidyselect_1.2.1 digest_0.6.37 future_1.40.0
#> [43] earthtide_0.1.7 listenv_0.9.1 dplyr_1.1.4
#> [46] purrr_1.0.4 splines_4.5.0 fastmap_1.2.0
#> [49] grid_4.5.0 colorspace_2.1-1 cli_3.6.5
#> [52] magrittr_2.0.3 utf8_1.2.4 survival_3.8-3
#> [55] future.apply_1.11.3 withr_3.0.2 Rmpfr_1.0-0
#> [58] scales_1.3.0 timechange_0.3.0 lubridate_1.9.4
#> [61] rmarkdown_2.29 httr_1.4.7 globals_0.17.0
#> [64] nnet_7.3-20 timeDate_4041.110 ragg_1.4.0
#> [67] evaluate_1.0.3 knitr_1.50 hardhat_1.4.1
#> [70] viridisLite_0.4.2 rlang_1.1.6 Rcpp_1.0.14
#> [73] glue_1.8.0 sparsevctrs_0.3.3 ipred_0.9-15
#> [76] jsonlite_2.0.0 R6_2.6.1 systemfonts_1.2.2
#> [79] fs_1.6.6