Skip to content

Instantly share code, notes, and snippets.

@coolbutuseless
Created September 10, 2020 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coolbutuseless/aa2a961f9c2a66549d18ca41938236f9 to your computer and use it in GitHub Desktop.
Save coolbutuseless/aa2a961f9c2a66549d18ca41938236f9 to your computer and use it in GitHub Desktop.
zstd quick bench
library(zstdlite)
set.seed(1)
bytes <- sample(as.raw(1:30), 1e6, replace = TRUE)
cz <- zstdlite::zstd_compress(bytes)
cb_gzip <- memCompress(bytes, type = 'gzip')
cb_bzip2 <- memCompress(bytes, type = 'bzip2')
cb_xz <- memCompress(bytes, type = 'xz')
length(cz)
length(cb_gzip)
length(cb_bzip2)
length(cb_xz)
uz <- zstdlite::zstd_decompress(cz)
ub <- memDecompress(cb, type = 'gzip')
bench::mark(
zstd_compress(bytes),
memCompress(bytes, type = 'gzip'),
memCompress(bytes, type = 'bzip2'),
memCompress(bytes, type = 'xz'),
check = FALSE
)
bench::mark(
zstd_decompress(cz),
memDecompress(cb_gzip , type = 'gzip'),
memDecompress(cb_bzip2, type = 'bzip2'),
memDecompress(cb_xz , type = 'xz'),
check = TRUE
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment