Skip to content

Commit

Permalink
Update dependencies and silence fast-float audit.
Browse files Browse the repository at this point in the history
Closes #21
Closes #22
Closes #23
Closes #24
Closes #25
  • Loading branch information
Alexhuszagh committed Dec 16, 2024
1 parent 5e3e3ce commit bc6c1e6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Bench

# TODO: Change back to dispatch
on:
[push, pull_request, workflow_dispatch]
[workflow_dispatch]

jobs:
bench:
Expand Down
3 changes: 2 additions & 1 deletion extras/simple-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ 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"] }
cargo-audit = "0.21.0"
45 changes: 28 additions & 17 deletions extras/simple-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>,
},

/// 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,
Expand Down Expand Up @@ -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()
Expand Down
13 changes: 0 additions & 13 deletions extras/simple-bench/src/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bc6c1e6

Please sign in to comment.