Skip to content

Instantly share code, notes, and snippets.

@knapply
Created August 10, 2020 14:40
Show Gist options
  • Save knapply/fcdc7dc2c3faececa06ea411dfbec855 to your computer and use it in GitHub Desktop.
Save knapply/fcdc7dc2c3faececa06ea411dfbec855 to your computer and use it in GitHub Desktop.
std::string_view(reinterpret_cast<const char*>(&(json[0])), std::size(json)) VS std::string(std::cbegin(json), std::cend(json))
scales::number_bytes(file.size(yuge_json_file))
##> [1] "890 MiB"
# parser.parse(
# std::string_view(reinterpret_cast<const char*>(&(json[0])), std::size(json))
# );
js_path <- yuge_json_file
raw_js <- readr::read_file_raw(js_path)
compressed_path <- "~/yuge.json.gz"
writeBin(memCompress(rawToChar(raw_js)), compressed_path)
microbenchmark::microbenchmark(
fparse(raw_js),
fload(compressed_path),
check = "identical",
times = 3
)
##> Unit: seconds
##> expr min lq mean median uq max neval
##> fparse(raw_js) 4.342298 4.549565 5.525309 4.756832 6.116815 7.476798 3
##> fload(compressed_path) 7.513787 8.121258 8.342995 8.728730 8.757599 8.786468 3
# parser.parse(std::string(std::cbegin(json), std::cend(json)));
js_path <- yuge_json_file
raw_js <- readr::read_file_raw(js_path)
compressed_path <- "~/yuge.json.gz"
microbenchmark::microbenchmark(
fparse(raw_js),
fload(compressed_path),
check = "identical",
times = 3
)
##> Unit: seconds
##> expr min lq mean median uq max neval
##> fparse(raw_js) 4.699747 5.143523 5.464226 5.587299 5.846466 6.105634 3
##> fload(compressed_path) 7.864278 7.987190 8.446771 8.110101 8.738018 9.365935 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment