Add size benchmark example (#276)

* test: add size bench example

* chore: update lock file
This commit is contained in:
Zixuan Chen 2024-02-28 21:59:20 +08:00 committed by GitHub
parent b8eb57f4a5
commit 17571ab6e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 49 additions and 1 deletions

45
Cargo.lock generated
View file

@ -178,6 +178,7 @@ version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"jobserver",
"libc",
]
@ -703,6 +704,15 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
[[package]]
name = "jobserver"
version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6"
dependencies = [
"libc",
]
[[package]]
name = "js-sys"
version = "0.3.63"
@ -821,6 +831,7 @@ dependencies = [
"tabled 0.10.0",
"thiserror",
"wasm-bindgen",
"zstd",
]
[[package]]
@ -1106,6 +1117,12 @@ dependencies = [
"siphasher",
]
[[package]]
name = "pkg-config"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]]
name = "plotters"
version = "0.3.4"
@ -1930,3 +1947,31 @@ name = "windows_x86_64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]]
name = "zstd"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bffb3309596d527cfcba7dfc6ed6052f1d39dfbd7c867aa2e865e4a449c10110"
dependencies = [
"zstd-safe",
]
[[package]]
name = "zstd-safe"
version = "7.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43747c7422e2924c11144d5229878b98180ef8b06cca4ab5af37afc8a8d8ea3e"
dependencies = [
"zstd-sys",
]
[[package]]
name = "zstd-sys"
version = "2.0.9+zstd.1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656"
dependencies = [
"cc",
"pkg-config",
]

View file

@ -60,6 +60,7 @@ ctor = "0.1.23"
criterion = "0.4.0"
arbtest = "0.2.0"
bench-utils = { path = "../bench-utils" }
zstd = "0.13.0"
# See https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html
[lib]

View file

@ -21,8 +21,10 @@ fn main() {
loro.diagnose_size();
drop(actions);
let start = Instant::now();
let mut size = 0;
for _ in 0..1 {
loro.export_snapshot();
size = loro.export_snapshot().len();
}
println!("Snapshot encoding time {}", start.elapsed().as_millis());
println!("Snapshot size {}", size);
}