From 98ef4d91f93f259753a7b4af051a786503f38efa Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Sun, 15 Dec 2024 20:31:31 -0600 Subject: [PATCH] Remove items as workspace files for our min required MSRV. --- .github/workflows/audit.yml | 3 +++ .github/workflows/bench.yml | 3 +-- Cargo.toml | 3 --- extras/simple-bench/Cargo.toml | 2 +- extras/simple-bench/src/main.rs | 45 +++++++++++++++++++------------ extras/simple-bench/src/random.rs | 13 --------- 6 files changed, 33 insertions(+), 36 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index be77e8a..88e1122 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -25,3 +25,6 @@ jobs: - uses: actions/checkout@v4 - uses: actions-rust-lang/audit@v1 name: Audit Rust Dependencies + with: + # fast-float is the crate we're replacing + ignore: RUSTSEC-2024-0379 diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 9d5f41a..8eb2d81 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -1,8 +1,7 @@ name: Bench -# TODO: Change back to dispatch on: - [push, pull_request, workflow_dispatch] + [workflow_dispatch] jobs: bench: diff --git a/Cargo.toml b/Cargo.toml index 24a3cee..0dde35b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,9 +33,6 @@ ryu = "1.0" fastrand = "2.1.1" num-bigint = "0.4.6" -[workspace] -members = [".", "extras/data-tests", "extras/simple-bench"] - [profile.release] lto = "fat" codegen-units = 1 diff --git a/extras/simple-bench/Cargo.toml b/extras/simple-bench/Cargo.toml index db3aec4..13d588e 100644 --- a/extras/simple-bench/Cargo.toml +++ b/extras/simple-bench/Cargo.toml @@ -9,9 +9,9 @@ publish = false [dependencies] fast-float2 = { path = "../.." } -structopt = "0.3" anyhow = "1.0" lexical = "7.0.4" lexical-core = "1.0.5" fastrand = "2.1.1" fast-float = "0.2" +clap = { version = "4.5.23", features = ["derive"] } diff --git a/extras/simple-bench/src/main.rs b/extras/simple-bench/src/main.rs index aaa2d49..dc95a79 100644 --- a/extras/simple-bench/src/main.rs +++ b/extras/simple-bench/src/main.rs @@ -6,60 +6,71 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use std::time::Instant; +use clap::Parser; use fast_float2::FastFloat; use fastrand::Rng; use lexical::FromLexical; use random::RandomGen; -use structopt::StructOpt; +//use structopt::StructOpt; -#[derive(Debug, StructOpt)] -#[structopt(name = "fast-float-simple-bench", about = "fast-float benchmark utility", no_version)] +#[derive(Parser, Debug)] +#[command(name = "fast-float-simple-bench", about = "fast-float benchmark utility")] struct Opt { /// Parse numbers as float32 (default is float64) - #[structopt(short, long = "32")] + #[arg(short, long = "32")] float32: bool, + /// How many times to repeat parsing - #[structopt(short, default_value = "1000")] + #[arg(short, long, default_value = "1000")] repeat: usize, + /// Only run fast-float benches - #[structopt(short)] + #[arg(short, long, default_value = "false")] only_fast_float: bool, - #[structopt(subcommand)] + + #[command(subcommand)] command: Cmd, } -#[derive(Debug, StructOpt)] +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] enum Cmd { /// Read the floats from file File { /// Input file (one number per line) - #[structopt(parse(from_os_str))] + #[arg(value_parser)] filename: PathBuf, }, + /// Generate random floats in (0, 1] Random { /// Random generator to be used - #[structopt( + #[arg( + value_enum, default_value = "uniform", - parse(try_from_str), - possible_values = RandomGen::variants() + //possible_values = RandomGen::variants() )] gen: RandomGen, + /// Number of random floats generated - #[structopt(short = "n", default_value = "50000")] + #[arg(short = 'n', default_value = "50000")] count: usize, + /// Random generator seed - #[structopt(short, default_value = "0")] + #[arg(short, default_value = "0")] seed: u64, + /// Also save the generated inputs to file - #[structopt(short = "f", parse(from_os_str))] + #[arg(value_parser, short = 'f')] filename: Option, }, + /// Run all benchmarks for fast-float only All { /// Number of random floats generated - #[structopt(short = "n", default_value = "50000")] + #[structopt(short = 'n', default_value = "50000")] count: usize, + /// Random generator seed #[structopt(short, default_value = "0")] seed: u64, @@ -263,7 +274,7 @@ impl Input { } fn main() { - let opt: Opt = StructOpt::from_args(); + let opt = Opt::parse(); let methods = if !opt.only_fast_float && !matches!(&opt.command, &Cmd::All { .. }) { Method::all().into() diff --git a/extras/simple-bench/src/random.rs b/extras/simple-bench/src/random.rs index 276bfed..a035214 100644 --- a/extras/simple-bench/src/random.rs +++ b/extras/simple-bench/src/random.rs @@ -50,19 +50,6 @@ impl FromStr for RandomGen { } impl RandomGen { - pub fn variants() -> &'static [&'static str] { - &[ - "uniform", - "one_over_rand32", - "simple_uniform32", - "simple_int32", - "int_e_int", - "simple_int64", - "bigint_int_dot_int", - "big_ints", - ] - } - pub fn all() -> &'static [Self] { &[ Self::Uniform,