Move the crypto benchmarks into a separate crate

Avoids issues from circular dev-dependency.
This commit is contained in:
Jonas Platte 2022-03-31 11:26:58 +02:00
parent 1e09577a8a
commit 9567f8f28f
No known key found for this signature in database
GPG Key ID: BBA95679259D342F
10 changed files with 35 additions and 29 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ target
master.zip
emsdk-*
.idea/
.vscode/

View File

@ -1,4 +1,4 @@
[workspace]
members = ["crates/*", "xtask"]
members = ["benchmarks", "crates/*", "xtask"]
# xtask should only be compiled when invoked explicitly
default-members = ["crates/*"]
default-members = ["benchmarks", "crates/*"]

25
benchmarks/Cargo.toml Normal file
View File

@ -0,0 +1,25 @@
[package]
name = "benchmarks"
description = "Matrix SDK benchmarks"
edition = "2021"
license = "Apache-2.0"
rust-version = "1.56"
version = "1.0.0"
publish = false
[dependencies]
criterion = { version = "0.3.4", features = ["async", "async_tokio", "html_reports"] }
matrix-sdk-crypto = { path = "../crates/matrix-sdk-crypto" }
matrix-sdk-sled = { path = "../crates/matrix-sdk-sled", default-features = false, features = ["crypto-store"] }
matrix-sdk-test = { path = "../crates/matrix-sdk-test" }
ruma = { git = "https://github.com/ruma/ruma", rev = "deea762b8" }
serde_json = "1.0.79"
tempfile = "3.2.0"
tokio = { version = "1.7.1", default-features = false, features = ["rt-multi-thread"] }
[target.'cfg(target_os = "linux")'.dependencies]
pprof = { version = "0.6.2", features = ["flamegraph", "criterion"] }
[[bench]]
name = "crypto_bench"
harness = false

View File

@ -26,7 +26,7 @@ fn alice_device_id() -> &'static DeviceId {
}
fn keys_query_response() -> get_keys::v3::Response {
let data = include_bytes!("./keys_query.json");
let data = include_bytes!("crypto_bench/keys_query.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
get_keys::v3::Response::try_from_http_response(data)
@ -34,7 +34,7 @@ fn keys_query_response() -> get_keys::v3::Response {
}
fn keys_claim_response() -> claim_keys::v3::Response {
let data = include_bytes!("./keys_claim.json");
let data = include_bytes!("crypto_bench/keys_claim.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
claim_keys::v3::Response::try_from_http_response(data)
@ -42,7 +42,7 @@ fn keys_claim_response() -> claim_keys::v3::Response {
}
fn huge_keys_query_response() -> get_keys::v3::Response {
let data = include_bytes!("./keys_query_2000_members.json");
let data = include_bytes!("crypto_bench/keys_query_2000_members.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
get_keys::v3::Response::try_from_http_response(data)

View File

@ -72,26 +72,6 @@ http = "0.2.4"
indoc = "1.0.3"
matches = "0.1.8"
matrix-sdk-test = { version = "0.4.0", path = "../matrix-sdk-test" }
# This is needed for the benchmarks
matrix-sdk-sled = { version = "0.1.0", path = "../matrix-sdk-sled", default-features = false, features = ["crypto-store"] }
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
criterion = { version = "0.3.4", features = [
"async",
"async_tokio",
"html_reports",
] }
proptest = "1.0.0"
tempfile = "3.2.0"
tokio = { version = "1.7.1", default-features = false, features = [
"rt-multi-thread",
"macros",
] }
[target.'cfg(target_os = "linux")'.dev-dependencies]
pprof = { version = "0.6.2", features = ["flamegraph", "criterion"] }
[[bench]]
name = "crypto_bench"
harness = false
# required for async_test macro
tokio = { version = "1.7.1", default-features = false, features = ["macros", "rt-multi-thread"] }

View File

@ -610,7 +610,7 @@ mod test {
}
fn keys_query_response() -> get_keys::v3::Response {
let data = include_bytes!("../../benches/keys_query.json");
let data = include_bytes!("../../../../benchmarks/benches/crypto_bench/keys_query.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
get_keys::v3::Response::try_from_http_response(data)
@ -618,7 +618,7 @@ mod test {
}
fn keys_claim_response() -> claim_keys::v3::Response {
let data = include_bytes!("../../benches/keys_claim.json");
let data = include_bytes!("../../../../benchmarks/benches/crypto_bench/keys_claim.json");
let data: Value = serde_json::from_slice(data).unwrap();
let data = response_from_file(&data);
claim_keys::v3::Response::try_from_http_response(data)