From e76d58d85fcf7dce9c43d40da5c1b3dfb57842d0 Mon Sep 17 00:00:00 2001 From: Lev Kruglyak Date: Fri, 7 Jun 2024 16:04:08 -0700 Subject: [PATCH] add in-memory size to benchmarker --- bench/instance/Cargo.lock | 11 +++++++++-- bench/instance/Cargo.toml | 1 + bench/instance/src/main.rs | 28 ++++++++++++++++++++++------ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/bench/instance/Cargo.lock b/bench/instance/Cargo.lock index df057b5..a871e17 100644 --- a/bench/instance/Cargo.lock +++ b/bench/instance/Cargo.lock @@ -75,9 +75,9 @@ dependencies = [ [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bincode" @@ -236,6 +236,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "fxhash" version = "0.2.1" @@ -376,6 +382,7 @@ version = "0.1.0" dependencies = [ "anyhow", "average", + "fs_extra", "limousine_bench", "limousine_engine", "sled", diff --git a/bench/instance/Cargo.toml b/bench/instance/Cargo.toml index e4d3e16..0fa8880 100644 --- a/bench/instance/Cargo.toml +++ b/bench/instance/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" average = "0.15.0" limousine_engine = { path = "../../engine", version = "0.3.4" } sled = "0.34.7" +fs_extra = "1.2.0" [build-dependencies] anyhow = "1.0.81" diff --git a/bench/instance/src/main.rs b/bench/instance/src/main.rs index bad5590..8b34ff3 100644 --- a/bench/instance/src/main.rs +++ b/bench/instance/src/main.rs @@ -14,10 +14,9 @@ type Key = i128; use std::{ io::{stdout, Write}, path::PathBuf, - time::{Duration, Instant}, + time::Instant, }; -use average::{Estimate, Variance}; use limousine_engine::prelude::*; use sled::IVec; @@ -77,8 +76,13 @@ fn main() { { std::fs::remove_dir_all(path.clone()).unwrap(); - let mut store: Instance> = Instance::open(path.join("store")).unwrap(); - let store_sled = sled::open(path.join("store_sled")).unwrap(); + + let store_path = path.join("store"); + let store_sled_path = path.join("store_sled"); + + let mut store: Instance> = + Instance::open(store_path.clone().join("store")).unwrap(); + let store_sled = sled::open(store_sled_path.clone()).unwrap(); let start = Instant::now(); for key in 0..size { @@ -94,11 +98,23 @@ fn main() { } let store_sled_end = start.elapsed(); + drop(store); + drop(store_sled); + + let store_sled_size = fs_extra::dir::get_size(store_sled_path).unwrap(); + let store_size = fs_extra::dir::get_size(store_path).unwrap(); + println!("[DONE]"); println!(); println!( - "insert: {:+.2e} ops/sec baseline speedup: {:.2}x", + "size: {:.2e} bytes baseline improvement: {:.2}x", + store_size as f64, + store_sled_size as f64 / store_size as f64 + ); + + println!( + "insert: {:.2e} ops/sec baseline improvement: {:.2}x", size as f64 / store_end.as_secs_f64(), store_sled_end.as_secs_f64() / store_end.as_secs_f64() ); @@ -121,7 +137,7 @@ fn main() { let store_sled_end = start.elapsed(); println!( - "search: {:+.2e} ops/sec baseline speedup: {:.2}x", + "search: {:.2e} ops/sec baseline improvement: {:.2}x", size as f64 / store_end.as_secs_f64(), store_sled_end.as_secs_f64() / store_end.as_secs_f64(), );