<commit_before># tt_trace_mre
a minimal rep example of using trace to count function evals in testthat unit tests<commit_msg>document first try in README<commit_after># testthat trace MRE

a minimal rep example of using `trace` to count function evals in `testthat` unit tests

## First Try

Based on [this](https://gist.github.com/rmflight/20f10db5c27b3623c321), I
implemented this:

```r
count_env <- new.env()

count_env$f1 <- count_env$f2 <- 0

trace(f1, tracer = quote(count_env$f1 <- count_env$f1 + 1), print = FALSE)
trace(f2, tracer = quote(count_env$f2 <- count_env$f2 + 1), print = FALSE)

test_that("f1 FALSE", {
  f1()
  expect_equal(1, count_env$f1)
  expect_equal(0, count_env$f2)
})
```

which has the problem of:

```r
object 'count_env' not found
```


{'fraction_non_alphanumeric': 0.12483745123537061, 'fraction_numerical': 0.04031209362808843, 'mean_word_length': 4.9689922480620154, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6008315', 'n_tokens_mistral': 307, 'n_tokens_neox': 283, 'n_words': 84}