bench icon indicating copy to clipboard operation
bench copied to clipboard

bench::mark results with a long unnamed expression don't print

Open nealrichardson opened this issue 5 years ago • 0 comments
trafficstars

If the expression you're benchmarking is sufficiently long, tibble's print method won't be able to fit it on screen, and it doesn't know how to ellipsize it like it would a regular character vector, so it just prints nothing. Here's a trivial example:

> bench::mark(as.character(as.character(as.character(as.character(as.character(letters))))))
# A tibble: 1 x 13
  expression                                                                   
  <bch:expr>                                                                   
1 as.character(as.character(as.character(as.character(as.character(letters)))))
# … with 12 more variables: min <bch:tm>, median <bch:tm>, `itr/sec` <dbl>,
#   mem_alloc <bch:byt>, `gc/sec` <dbl>, n_itr <int>, n_gc <dbl>,
#   total_time <bch:tm>, result <list>, memory <list>, time <list>, gc <list>

> bench::mark(as.character(as.character(as.character(as.character(as.character(as.character(letters)))))))
# A tibble: 1 x 13
# … with 13 more variables: expression <bch:expr>, min <bch:tm>,
#   median <bch:tm>, `itr/sec` <dbl>, mem_alloc <bch:byt>, `gc/sec` <dbl>,
#   n_itr <int>, n_gc <dbl>, total_time <bch:tm>, result <list>, memory <list>,
#   time <list>, gc <list>
>

The workaround is to name the expression, like I did here.

I'm not sure if this is something that can be solved with a print method for bench_expr, or if there should be an acknowledgement of the issue and a recommendation to name the expressions, or something else.

nealrichardson avatar Jul 27 '20 18:07 nealrichardson