File: rename-slow-tests.R

package info (click to toggle)
duckdb 1.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 299,196 kB
  • sloc: cpp: 865,414; ansic: 57,292; python: 18,871; sql: 12,663; lisp: 11,751; yacc: 7,412; lex: 1,682; sh: 747; makefile: 558
file content (48 lines) | stat: -rw-r--r-- 1,212 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
library(tidyverse)

here <- rprojroot::is_git_root$find_file

# build/debug/test/unittest -d yes 2>&1 > timings.txt
timings <- readLines(here("timings.txt"))

timings
timings_df <- rematch2::re_match(timings, "^.*(?<time>[0-9][.][0-9][0-9][0-9]) s: (?<desc>.*)$")

cum_timings_df <-
  timings_df %>%
  filter(!is.na(time)) %>%
  mutate(time = as.numeric(time)) %>%
  count(desc, wt = time, name = "time") %>%
  arrange(time) %>%
  mutate(cum_time = cumsum(time), id = row_number())

cum_timings_df %>%
  ggplot(aes(x = time, y = cum_time, color = id)) +
  geom_line() +
  scale_x_log10()

cum_timings_df %>%
  ggplot(aes(x = id, y = cum_time, color = time)) +
  geom_line() +
  scale_colour_continuous(trans = "log10")

cum_timings_cut <-
  cum_timings_df %>%
  filter(cum_time >= 200, str_detect(desc, "[.]test$"))

slow <- cum_timings_cut$desc
slow_renamed <- paste0(slow, "_coverage")

slow_renamed[fs::file_exists(here(slow_renamed))]
stopifnot(!any(fs::file_exists(here(slow_renamed))))

withr::with_dir(
  here(),
  fs::file_move(slow, slow_renamed)
)

walk2(slow_renamed, slow, ~ {
  text <- brio::read_lines(here(.x))
  text <- str_replace_all(text, fixed(.y), .x)
  brio::write_lines(text, here(.x))
})