Skip to content

Commit 7fa178e

Browse files
authored
Merge pull request #1564 from exploratory-io/enable/chaid-perf-always-on
test(chaid): always run perf guardrails with 2x budgets
2 parents e294d67 + e559855 commit 7fa178e

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

tests/testthat/test_chaid_perf.R

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# CHAID performance guardrails. Skipped by default; run with
2-
# EXPLORATORY_RUN_PERF=1 Rscript -e '...test_file("tests/testthat/test_chaid_perf.R")'
3-
# Budgets are generous relative to observed times (10k x 20 ~0.4s,
4-
# 100k x 50 ~3s on an M1 Mac) so they catch regressions, not noise.
1+
# CHAID performance guardrails. Always run in the normal testthat suite.
2+
# Budgets are ~2x measured Daily-machine times so parallel/loaded runs still
3+
# pass: Mac M5 ~0.6/4.4/1.1s, Win Azure 4-core ~2.5/17/6.4s for the three cases.
54

65
make_chaid_data <- function(n, p, seed = 1) {
76
set.seed(seed)
@@ -19,29 +18,26 @@ make_chaid_data <- function(n, p, seed = 1) {
1918
}
2019

2120
test_that('CHAID fits 10k x 20 within budget', {
22-
skip_if(Sys.getenv('EXPLORATORY_RUN_PERF') == '', 'perf tests are opt-in')
2321
df <- make_chaid_data(10000, 20)
2422
elapsed <- system.time(suppressWarnings(
2523
chaid_fit(df, target = 'target', predictors = paste0('v', 1:20),
2624
max_depth = 4, min_split = 100, min_bucket = 30)
2725
))[['elapsed']]
28-
expect_lt(elapsed, 10)
26+
expect_lt(elapsed, 20)
2927
})
3028

3129
test_that('CHAID fits 100k x 50 within budget', {
32-
skip_if(Sys.getenv('EXPLORATORY_RUN_PERF') == '', 'perf tests are opt-in')
3330
df <- make_chaid_data(100000, 50)
3431
elapsed <- system.time(suppressWarnings(
3532
chaid_fit(df, target = 'target', predictors = paste0('v', 1:50),
3633
max_depth = 4, min_split = 500, min_bucket = 100)
3734
))[['elapsed']]
38-
expect_lt(elapsed, 90)
35+
expect_lt(elapsed, 180)
3936
})
4037

4138
test_that('permutation importance on 20k x 20 stays fast', {
42-
skip_if(Sys.getenv('EXPLORATORY_RUN_PERF') == '', 'perf tests are opt-in')
4339
# Before vectorizing prediction this took ~10 minutes (201 predictions, each a
44-
# per-row tree walk). Budget is generous relative to the observed ~0.4s.
40+
# per-row tree walk). Budget is 2x measured Win Daily (~6.4s) for parallel load.
4541
df <- make_chaid_data(20000, 20)
4642
predictors <- paste0('v', 1:20)
4743
model <- suppressWarnings(
@@ -51,5 +47,5 @@ test_that('permutation importance on 20k x 20 stays fast', {
5147
elapsed <- system.time(
5248
chaid_permutation_importance(model, df, 'target', predictors)
5349
)[['elapsed']]
54-
expect_lt(elapsed, 30)
50+
expect_lt(elapsed, 60)
5551
})

0 commit comments

Comments
 (0)