From 69f70cfe72b050f989cc2479ec4805712962955f Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Fri, 16 Feb 2018 09:38:12 -0800 Subject: [PATCH] Add separate benchmarks for seq and par versions of verify_slice --- README.md | 25 ++++++++++++++++++++++++- src/event.rs | 9 +++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 23b5ec7c3e..1646cad8e2 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,15 @@ An implementation of Loom's Proof-of-History. # Developing -Install Rust and Cargo: +Building +--- + +Install rustc, cargo and rustfmt: ```bash $ curl https://sh.rustup.rs -sSf | sh +$ source $HOME/.cargo/env +$ rustup component add rustfmt-preview ``` Download the source code: @@ -21,8 +26,26 @@ $ git clone https://github.com/garious/phist.git $ cd phist ``` +Testing +--- + Run the test suite: ```bash cargo test ``` + +Benchmarking +--- + +First install the nightly build of rustc. `cargo bench` requires unstable features: + +```bash +$ rustup install nightly +``` + +Run the benchmarks: + +```bash +$ cargo +nightly bench --features="unstable" +``` diff --git a/src/event.rs b/src/event.rs index d46f65bf93..c1e08d483f 100644 --- a/src/event.rs +++ b/src/event.rs @@ -133,6 +133,15 @@ mod bench { #[bench] fn event_bench(bencher: &mut Bencher) { + let start_hash = 0; + let events = event::create_ticks(start_hash, 100_000, 8); + bencher.iter(|| { + assert!(event::verify_slice(&events, start_hash)); + }); + } + + #[bench] + fn event_bench_seq(bencher: &mut Bencher) { let start_hash = 0; let events = event::create_ticks(start_hash, 100_000, 8); bencher.iter(|| {