Skip to content

Update dependencies and silence fast-float audit. #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 16, 2024
Merged
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
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
12 changes: 8 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ readme = "README.md"
license = "MIT OR Apache-2.0"
autobenches = false
edition = "2018"
exclude = ["benches/*", "extras/*"]
exclude = [
"benches/*",
"extras/*",
"clippy.toml",
"rustfmt.toml",
"SECURITY.md",
".git*",
]
# FIXME: rust-version is not supported until 1.56.0.
rust-version = "1.37"

Expand All @@ -26,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
Expand Down
2 changes: 1 addition & 1 deletion extras/simple-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
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
Loading