Skip to content

Commit

Permalink
supply more informative axis breaks in scale_*_bench_*()
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Jul 15, 2024
1 parent 8d4ab5e commit 84d9311
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# bench (development version)

* `scale_*_bench_*()` functions now supply more informative axis breaks
(@simonpcouch, #143).

# bench 1.1.3

* Long unnamed `bench_expr` expressions are now truncated correctly when used as
Expand Down
4 changes: 2 additions & 2 deletions R/bytes.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ bench_bytes_trans <- function(base = 2) {
if (is.null(base)) {
return(
scales::trans_new("bch:byt", as.numeric, as_bench_bytes,
scales::pretty_breaks(), domain = c(1e-100, Inf)
breaks = scales::pretty_breaks(), domain = c(1e-100, Inf)
)
)
}
trans <- function(x) log(as.numeric(x), base)
inv <- function(x) as_bench_bytes(base ^ as.numeric(x))

scales::trans_new(paste0("bch:byt-", format(base)), trans, inv,
scales::log_breaks(base = base), domain = c(1e-100, Inf))
breaks = scales::log_breaks(base = base), domain = c(1e-100, Inf))
}

scale_type.bench_bytes <- function(x) "bench_bytes"
Expand Down

0 comments on commit 84d9311

Please sign in to comment.