Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: test
args: --release
Binary file modified data.zip
Binary file not shown.
60 changes: 59 additions & 1 deletion examples/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,61 @@ use criterion::black_box;

use tracing::Level;

#[derive(Debug)]
enum Libraries {
Ruth,
Small,
Default,
Transitive,
All,
}

impl FromStr for Libraries {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(match s {
"ruth" => Libraries::Ruth,
"small" => Libraries::Small,
"default" => Libraries::Default,
"transitive" => Libraries::Transitive,
"all" => Libraries::All,
_ => return Err("Could not parse".to_string()),
})
}
}

impl Default for Libraries {
fn default() -> Self {
Libraries::Default
}
}

impl ToString for Libraries {
fn to_string(&self) -> String {
match self {
Libraries::Ruth => "ruth",
Libraries::Small => "small",
Libraries::Default => "default",
Libraries::Transitive => "transitive",
Libraries::All => "all",
}
.to_string()
}
}

impl Libraries {
fn paths(&self) -> Vec<&str> {
match self {
Libraries::Ruth => vec!["data/ruth.json"],
Libraries::Small => vec!["data/small.json"],
Libraries::Default => vec!["data/small.json", "data/transitive.json"],
Libraries::Transitive => vec!["data/transitive.json"],
Libraries::All => vec!["data/ruth.json", "data/small.json", "data/transitive.json"],
}
}
}

#[derive(Debug)]
enum BenchMode {
Deterministic,
Expand Down Expand Up @@ -55,6 +110,9 @@ fn group_library(path: &str) -> impl IntoIterator<Item = DecoratedGroup<DefaultP
struct Arguments {
#[structopt(short, long)]
mode: BenchMode,

#[structopt(default_value, short, long)]
libraries: Libraries,
}

fn bench<S: BuilderStrategy<DefaultPermutation> + Clone>(lib: Vec<DecoratedGroup>, strategy: S) {
Expand Down Expand Up @@ -91,7 +149,7 @@ fn main() {

println!("Loading libraries");

let group_library = load_libraries(&["data/small.json", "data/transitive.json"]);
let group_library = load_libraries(&args.libraries.paths());

println!("Libraries loaded");

Expand Down
Loading