summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Batischev <eual.jp@gmail.com>2021-09-23 19:49:23 +0000
committerAlexander Batischev <eual.jp@gmail.com>2021-09-23 19:49:23 +0000
commit9435d7a9e4a109c747976b25fcd2c43556d9081d (patch)
treef67dc43f58edb5c05b3fee65e287dd53ea5b38c8
parent7d037bdf8231f14c668cc36789ca2873ccaf3b45 (diff)
parent5768dd1112ef4ebc6040c50d9a64e08989dc0c6a (diff)
downloadobnam2-9435d7a9e4a109c747976b25fcd2c43556d9081d.tar.gz
Merge branch 'benchmarks' into 'main'
drop: benchmark programs Closes #131 See merge request obnam/obnam!184
-rw-r--r--src/bin/benchmark-index.rs94
-rw-r--r--src/bin/benchmark-indexedstore.rs93
-rw-r--r--src/bin/benchmark-null.rs27
-rw-r--r--src/bin/benchmark-store.rs28
4 files changed, 0 insertions, 242 deletions
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(())
-}