Skip to content

Commit

Permalink
benchmark redis
Browse files Browse the repository at this point in the history
  • Loading branch information
gauteh committed May 5, 2022
1 parent 2039161 commit f51ef9d
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 2 deletions.
68 changes: 66 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ heed = "0.11.0"
ndarray = "0.15"
rand = "0.8"
rayon = "1.5.0"
redis = "0.21.5"
sled = "0.34.6"
sqlx = { version = "0.5", features = [ "macros", "sqlite", "runtime-tokio-rustls" ] }
tempfile = "3.3.0"
Expand Down
46 changes: 46 additions & 0 deletions benches/serde_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,49 @@ mod serde_db_heed {
})
}
}

mod serde_db_redis {
// Requires redis: docker run --rm -p 6379:6379 redis

use super::*;
use redis::Commands;

#[ignore]
#[bench]
fn deserialize_meps_bincode(b: &mut Bencher) {
let i = Index::index("tests/data/meps_det_vc_2_5km_latest.nc").unwrap();

let bts = bincode::serialize(&i).unwrap();

let mut db = redis::Client::open("redis://:@127.1:6379")
.unwrap()
.get_connection()
.unwrap();

db.set::<_, _, ()>("meps", bts.as_slice()).unwrap();

b.iter(|| {
let nbts: Vec<u8> = db.get("meps").unwrap();
test::black_box(bincode::deserialize::<Index>(&nbts).unwrap());
})
}

#[ignore]
#[bench]
fn deserialize_meps_bincode_only_read(b: &mut Bencher) {
let i = Index::index("tests/data/meps_det_vc_2_5km_latest.nc").unwrap();

let bts = bincode::serialize(&i).unwrap();

let mut db = redis::Client::open("redis://:@127.1:6379")
.unwrap()
.get_connection()
.unwrap();

db.set::<_, _, ()>("meps", bts.as_slice()).unwrap();

b.iter(|| {
let _nbts: Vec<u8> = test::black_box(db.get("meps").unwrap());
})
}
}

0 comments on commit f51ef9d

Please sign in to comment.