Skip to content

Commit

Permalink
Merge branch 'main' into addins
Browse files Browse the repository at this point in the history
  • Loading branch information
Polkas authored Jan 27, 2025
2 parents 6d10f1d + d7a1e76 commit 2516ce4
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ Cargo.lock
# MacOS
.DS_Store

# RStudio
.Rproj.user
tergo.Rproj

8 changes: 7 additions & 1 deletion antidotum/tergo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ instead of slow running alternatives. Save tens of hours on your monthly bill!
the user to see and other styling libraries don't cut it in terms of speed
and efficiency.

`tergo` is **REALLY FAST**.
`tergo` is **Faster than Blink of an Eye**. First run is more **x100 faster** or for bigger repositories even **x1000 faster** than other available solutions.

![First Run](./man/figures/first_run.png)

Yes, tergo is there but it takes less than 0.1 seconds so is not visible!!!

Benchmarking code is available in `inst/bench.R`.

## Installation

Expand Down
80 changes: 80 additions & 0 deletions antidotum/tergo/inst/bench.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Run on Mac M1
# Dependencies: git2r, styler, tergo, microbenchmark, ggplot2
# install.packages(c("git2r", "tergo", "styler", "microbenchmark", "ggplot2"))
require(git2r)
require(tergo)
require(styler)
require(microbenchmark)
require(ggplot2)

tempd <- tempdir()
bench_path <- file.path(tempd, "bench")
dir.create(bench_path)

pacs <- c(
"dplyr" = "https://github.com/tidyverse/dplyr",
"ggplot2" = "https://github.com/tidyverse/ggplot2",
"shiny" = "https://github.com/rstudio/shiny"
)

results <- list()
results2 <- list()

for (pac in names(pacs)) {
pac_path <- file.path(bench_path, pac)
pac_path_styler <- file.path(pac_path, "styler")
pac_path_tergo <- file.path(pac_path, "tergo")

# Independent so second styling is no rerunning
git2r::clone(pacs[pac], pac_path_styler, progress = FALSE)
git2r::clone(pacs[pac], pac_path_tergo, progress = FALSE)

results[[pac]] <- microbenchmark::microbenchmark(
styler = {
styler::style_pkg(pac_path_styler, filetype = "R", dry = "off")
},
tergo = {
tergo::style_pkg(pac_path_tergo)
},
times = 1,
unit = "s"
)

results2[[pac]] <- microbenchmark::microbenchmark(
styler = {
styler::style_pkg(pac_path_styler, filetype = "R", dry = "off")
},
tergo = {
tergo::style_pkg(pac_path_tergo)
},
times = 1,
unit = "s"
)
}

results_df <- do.call(
rbind,
lapply(names(results), function(x) cbind(summary(results[[x]])[, c("expr", "median")], package = x))
)

gg <- ggplot2::ggplot(results_df, ggplot2::aes(x = package, y = median)) +
ggplot2::geom_bar(ggplot2::aes(fill = expr), stat = "identity", position = "dodge") +
ggplot2::ggtitle("First Run\nSeconds to Style the Whole package x\nstyler vs tergo") +
ggplot2::coord_flip() +
ggplot2::labs(y = "seconds")

ggplot2::ggsave("man/figures/first_run.png", gg)

results2_df <- do.call(
rbind,
lapply(names(results), function(x) cbind(summary(results2[[x]])[, c("expr", "median")], package = x))
)

gg2 <- ggplot2::ggplot(results2_df, ggplot2::aes(x = package, y = median)) +
ggplot2::geom_bar(ggplot2::aes(fill = expr), stat = "identity", position = "dodge") +
ggplot2::coord_flip() +
ggplot2::ggtitle("Second and Subsequent Runs\nSeconds to Style the Whole package x\nstyler vs tergo") +
ggplot2::labs(y = "seconds")

ggplot2::ggsave("man/figures/second_run.png", gg2)

Binary file added antidotum/tergo/man/figures/first_run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added antidotum/tergo/man/figures/second_run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2516ce4

Please sign in to comment.