Closed schloerke closed 3 years ago
Fixes #406
*.txt
digest::digest(raw_data, algo = "sha1")
.(json|download|txt|png)
app$snapshot
.json
Before PR:
With PR:
SHA1 spelling came from https://en.wikipedia.org/wiki/SHA-1
Benchmark of sha1, md5, and spookyhash.
sha1
md5
spookyhash
a <- read_raw("pr407/tests/shinytest/test-expected-old/test") # "small" file bench::mark( md5 = digest::digest(a), spooky = digest::digest(a, algo = "spookyhash"), sha1 = digest::digest(a, algo = "sha1"), check = FALSE ) #> # A tibble: 3 × 13 #> expression min median `itr/sec` mem_alloc `gc/sec` n_itr n_gc total_time result memory time gc #> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl> <int> <dbl> <bch:tm> <list> <list> <list> <list> #> 1 md5 18.8µs 25.5µs 38118. 8.63KB 11.4 9997 3 262ms <NULL> <Rprofmem… <bench_t… <tibble … #> 2 spooky 24µs 30.7µs 32743. 8.63KB 9.83 9997 3 305ms <NULL> <Rprofmem… <bench_t… <tibble … #> 3 sha1 21.7µs 28.9µs 35311. 8.63KB 14.1 9996 4 283ms <NULL> <Rprofmem… <bench_t… <tibble … # 1000x sizeof("small" file) bench::mark( md5 = digest::digest(b), spooky = digest::digest(b, algo = "spookyhash"), sha1 = digest::digest(b, algo = "sha1"), check = FALSE ) #> # A tibble: 3 × 13 #> expression min median `itr/sec` mem_alloc `gc/sec` n_itr n_gc total_time result memory time gc #> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl> <int> <dbl> <bch:tm> <list> <list> <list> <list> #> 1 md5 212.8µs 262.2µs 3400. 101.19KB 6.43 1585 3 466ms <NULL> <Rprofmem… <bench_t… <tibble … #> 2 spooky 30.1µs 36.1µs 25985. 8.63KB 7.80 9997 3 385ms <NULL> <Rprofmem… <bench_t… <tibble … #> 3 sha1 216.7µs 236.6µs 3981. 90.73KB 8.63 1846 4 464ms <NULL> <Rprofmem… <bench_t… <tibble …
The results are still less than a millisecond, so using the familiar sha1 as the result does not need to be crypto perfect, just signal differences.
All comments addressed. Merging.
Fixes #406
*.txt
filesdigest::digest(raw_data, algo = "sha1")
on non.(json|download|txt|png)
filesapp$snapshot
to encourage using a.json
file extensionBefore PR:
With PR:
SHA1 spelling came from https://en.wikipedia.org/wiki/SHA-1
Benchmark of
sha1
,md5
, andspookyhash
.The results are still less than a millisecond, so using the familiar
sha1
as the result does not need to be crypto perfect, just signal differences.