0

I'm trying to augment the benchmarks in this article with the tidytable package](https://www.tidyverse.org/blog/2023/04/performant-packages/#tools-of-the-trade).

When I add tidytable to a benchmark, I get a strange error:

Error: Each result must equal the first result: t_tidytable does not equal t_dplyr

library(dtplyr)
library(tidyverse)
library(profvis)
library(bench)
library(vctrs)
#> 
#> Attaching package: 'vctrs'
#> The following object is masked from 'package:dplyr':
#> 
#>     data_frame
#> The following object is masked from 'package:tibble':
#> 
#>     data_frame
library(data.table)
#> 
#> Attaching package: 'data.table'
#> The following objects are masked from 'package:lubridate':
#> 
#>     hour, isoweek, mday, minute, month, quarter, second, wday, week,
#>     yday, year
#> The following objects are masked from 'package:dplyr':
#> 
#>     between, first, last
#> The following object is masked from 'package:purrr':
#> 
#>     transpose

mtcars_tbl = tibble::as_tibble(mtcars, rownames = "make_model")

res =
  bench::mark(
    t_dplyr = dplyr::filter(mtcars_tbl, hp > 100),
    t_vctr = vec_slice(mtcars_tbl, mtcars_tbl$hp > 100),
    t_datatable = mtcars_tbl[mtcars_tbl$hp > 100, ]
  ) %>%
  select(expression, median)

res =
  bench::mark(
    t_tidytable = tidytable::filter(mtcars_tbl, hp > 100),
    t_dplyr = dplyr::filter(mtcars_tbl, hp > 100),
    t_vctr = vec_slice(mtcars_tbl, mtcars_tbl$hp > 100),
    t_datatable = mtcars_tbl[mtcars_tbl$hp > 100, ]
  ) %>%
  select(expression, median)
#> Error: Each result must equal the first result:
#> `t_tidytable` does not equal `t_dplyr`

Created on 2023-04-29 with reprex v2.0.2

abalter
  • 9,663
  • 17
  • 90
  • 145
  • 4
    The `check` parameter of `bench::mark()` uses `all.equal()` to check that all the results are the same. In this case, they will have different classes. Docs: https://bench.r-lib.org/reference/mark.html – alistaire Apr 30 '23 at 00:23
  • 3
    Moreover, you are not actually using `data.table`. You are simply subseting a data.frame. If you want to check how data.table performs, you need to use `setDT()` first. In that case, the first instance also would return the same error. – M-- Apr 30 '23 at 02:08

0 Answers0