From 5768dd1112ef4ebc6040c50d9a64e08989dc0c6a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Thu, 23 Sep 2021 19:42:49 +0300 Subject: drop: benchmark programs I think we need to re-think the way we do benchmarks. These old programs aren't useful anymore. We definitely want to run benchmarks via "cargo bench" rather than having extra binaries in the crate. Sponsored-by: author --- src/bin/benchmark-index.rs | 94 --------------------------------------- src/bin/benchmark-indexedstore.rs | 93 -------------------------------------- src/bin/benchmark-null.rs | 27 ----------- src/bin/benchmark-store.rs | 28 ------------ 4 files changed, 242 deletions(-) delete mode 100644 src/bin/benchmark-index.rs delete mode 100644 src/bin/benchmark-indexedstore.rs delete mode 100644 src/bin/benchmark-null.rs delete mode 100644 src/bin/benchmark-store.rs diff --git a/src/bin/benchmark-index.rs b/src/bin/benchmark-index.rs deleted file mode 100644 index 4df8354..0000000 --- a/src/bin/benchmark-index.rs +++ /dev/null @@ -1,94 +0,0 @@ -use obnam::benchmark::ChunkGenerator; -use obnam::index::Index; -use std::path::{Path, PathBuf}; -use std::time::SystemTime; -use structopt::StructOpt; - -#[derive(Debug, StructOpt)] -#[structopt( - name = "benchmark-index", - about = "Benhcmark the chunk store index without HTTP" -)] -enum Opt { - Create { - #[structopt(parse(from_os_str))] - chunks: PathBuf, - - #[structopt()] - num: u32, - }, - - Lookup { - #[structopt(parse(from_os_str))] - chunks: PathBuf, - - #[structopt()] - warmup_count: u32, - - #[structopt()] - hot_count: u32, - }, -} - -fn main() -> anyhow::Result<()> { - pretty_env_logger::init(); - - let opt = Opt::from_args(); - - match opt { - Opt::Create { chunks, num } => create(&chunks, num)?, - Opt::Lookup { - chunks, - warmup_count, - hot_count, - } => { - let mut index = Index::new(chunks)?; - let time = SystemTime::now(); - warmup(&mut index, warmup_count)?; - let warmup_time = time.elapsed()?; - hot(&mut index, hot_count)?; - let hot_time = time.elapsed()? - warmup_time; - println!("warmup {}", warmup_time.as_millis()); - println!("hot {}", hot_time.as_millis()); - } - } - - Ok(()) -} - -fn create(chunks: &Path, num: u32) -> anyhow::Result<()> { - let mut index = Index::new(chunks)?; - let gen = ChunkGenerator::new(num); - - for (id, _, chunk) in gen { - let meta = (*chunk.meta()).clone(); - index.insert_meta(id, meta)?; - } - - Ok(()) -} - -fn warmup(index: &mut Index, num: u32) -> anyhow::Result<()> { - println!("warming up cache"); - lookup(index, num) -} - -fn hot(index: &mut Index, num: u32) -> anyhow::Result<()> { - println!("using hot cache"); - lookup(index, num) -} - -fn lookup(index: &mut Index, num: u32) -> anyhow::Result<()> { - let mut done = 0; - - loop { - let gen = ChunkGenerator::new(num); - for (_, _, chunk) in gen { - index.find_by_sha256(chunk.meta().sha256())?; - done += 1; - if done >= num { - return Ok(()); - } - } - } -} diff --git a/src/bin/benchmark-indexedstore.rs b/src/bin/benchmark-indexedstore.rs deleted file mode 100644 index 1479cb9..0000000 --- a/src/bin/benchmark-indexedstore.rs +++ /dev/null @@ -1,93 +0,0 @@ -use obnam::benchmark::ChunkGenerator; -use obnam::indexedstore::IndexedStore; -use std::path::{Path, PathBuf}; -use std::time::SystemTime; -use structopt::StructOpt; - -#[derive(Debug, StructOpt)] -#[structopt( - name = "benchmark-indexedstore", - about = "Benhcmark the store without HTTP" -)] -enum Opt { - Create { - #[structopt(parse(from_os_str))] - chunks: PathBuf, - - #[structopt()] - num: u32, - }, - - Lookup { - #[structopt(parse(from_os_str))] - chunks: PathBuf, - - #[structopt()] - warmup_count: u32, - - #[structopt()] - hot_count: u32, - }, -} - -fn main() -> anyhow::Result<()> { - pretty_env_logger::init(); - - let opt = Opt::from_args(); - - match opt { - Opt::Create { chunks, num } => create(&chunks, num)?, - Opt::Lookup { - chunks, - warmup_count, - hot_count, - } => { - let mut index = IndexedStore::new(&chunks)?; - let time = SystemTime::now(); - warmup(&mut index, warmup_count)?; - let warmup_time = time.elapsed()?; - hot(&mut index, hot_count)?; - let hot_time = time.elapsed()? - warmup_time; - println!("warmup {}", warmup_time.as_millis()); - println!("hot {}", hot_time.as_millis()); - } - } - - Ok(()) -} - -fn create(chunks: &Path, num: u32) -> anyhow::Result<()> { - let mut store = IndexedStore::new(chunks)?; - let gen = ChunkGenerator::new(num); - - for (_, _, chunk) in gen { - store.save(&chunk)?; - } - - Ok(()) -} - -fn warmup(index: &mut IndexedStore, num: u32) -> anyhow::Result<()> { - println!("warming up cache"); - lookup(index, num) -} - -fn hot(index: &mut IndexedStore, num: u32) -> anyhow::Result<()> { - println!("using hot cache"); - lookup(index, num) -} - -fn lookup(index: &mut IndexedStore, num: u32) -> anyhow::Result<()> { - let mut done = 0; - - loop { - let gen = ChunkGenerator::new(num); - for (_, _, chunk) in gen { - index.find_by_sha256(chunk.meta().sha256())?; - done += 1; - if done >= num { - return Ok(()); - } - } - } -} diff --git a/src/bin/benchmark-null.rs b/src/bin/benchmark-null.rs deleted file mode 100644 index fc60a77..0000000 --- a/src/bin/benchmark-null.rs +++ /dev/null @@ -1,27 +0,0 @@ -use obnam::benchmark::ChunkGenerator; -use std::path::PathBuf; -use structopt::StructOpt; - -#[derive(Debug, StructOpt)] -#[structopt( - name = "benchmark-index", - about = "Benhcmark the store index in memory" -)] -struct Opt { - // We don't use this, but we accept it for command line - // compatibility with other benchmark programs. - #[structopt(parse(from_os_str))] - chunks: PathBuf, - - #[structopt()] - num: u32, -} - -fn main() { - pretty_env_logger::init(); - - let opt = Opt::from_args(); - let gen = ChunkGenerator::new(opt.num); - - for (_, _, _) in gen {} -} diff --git a/src/bin/benchmark-store.rs b/src/bin/benchmark-store.rs deleted file mode 100644 index da54590..0000000 --- a/src/bin/benchmark-store.rs +++ /dev/null @@ -1,28 +0,0 @@ -use obnam::benchmark::ChunkGenerator; -use obnam::store::Store; -use std::path::PathBuf; -use structopt::StructOpt; - -#[derive(Debug, StructOpt)] -#[structopt(name = "benchmark-store", about = "Benhcmark the store without HTTP")] -struct Opt { - #[structopt(parse(from_os_str))] - chunks: PathBuf, - - #[structopt()] - num: u32, -} - -fn main() -> anyhow::Result<()> { - pretty_env_logger::init(); - - let opt = Opt::from_args(); - let gen = ChunkGenerator::new(opt.num); - - let store = Store::new(&opt.chunks); - for (id, _, chunk) in gen { - store.save(&id, &chunk)?; - } - - Ok(()) -} -- cgit v1.2.1