Skip to content

Commit bc6c1e6

Browse files
committed
Update dependencies and silence fast-float audit.
Closes #21 Closes #22 Closes #23 Closes #24 Closes #25
1 parent 5e3e3ce commit bc6c1e6

File tree

5 files changed

+34
-33
lines changed

5 files changed

+34
-33
lines changed

.github/workflows/audit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ jobs:
2525
- uses: actions/checkout@v4
2626
- uses: actions-rust-lang/audit@v1
2727
name: Audit Rust Dependencies
28+
with:
29+
# fast-float is the crate we're replacing
30+
ignore: RUSTSEC-2024-0379

.github/workflows/bench.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: Bench
22

3-
# TODO: Change back to dispatch
43
on:
5-
[push, pull_request, workflow_dispatch]
4+
[workflow_dispatch]
65

76
jobs:
87
bench:

extras/simple-bench/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ publish = false
99

1010
[dependencies]
1111
fast-float2 = { path = "../.." }
12-
structopt = "0.3"
1312
anyhow = "1.0"
1413
lexical = "7.0.4"
1514
lexical-core = "1.0.5"
1615
fastrand = "2.1.1"
1716
fast-float = "0.2"
17+
clap = { version = "4.5.23", features = ["derive"] }
18+
cargo-audit = "0.21.0"

extras/simple-bench/src/main.rs

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,60 +6,71 @@ use std::path::{Path, PathBuf};
66
use std::str::FromStr;
77
use std::time::Instant;
88

9+
use clap::Parser;
910
use fast_float2::FastFloat;
1011
use fastrand::Rng;
1112
use lexical::FromLexical;
1213
use random::RandomGen;
13-
use structopt::StructOpt;
14+
//use structopt::StructOpt;
1415

15-
#[derive(Debug, StructOpt)]
16-
#[structopt(name = "fast-float-simple-bench", about = "fast-float benchmark utility", no_version)]
16+
#[derive(Parser, Debug)]
17+
#[command(name = "fast-float-simple-bench", about = "fast-float benchmark utility")]
1718
struct Opt {
1819
/// Parse numbers as float32 (default is float64)
19-
#[structopt(short, long = "32")]
20+
#[arg(short, long = "32")]
2021
float32: bool,
22+
2123
/// How many times to repeat parsing
22-
#[structopt(short, default_value = "1000")]
24+
#[arg(short, long, default_value = "1000")]
2325
repeat: usize,
26+
2427
/// Only run fast-float benches
25-
#[structopt(short)]
28+
#[arg(short, long, default_value = "false")]
2629
only_fast_float: bool,
27-
#[structopt(subcommand)]
30+
31+
#[command(subcommand)]
2832
command: Cmd,
2933
}
3034

31-
#[derive(Debug, StructOpt)]
35+
#[derive(Parser, Debug)]
36+
#[command(version, about, long_about = None)]
3237
enum Cmd {
3338
/// Read the floats from file
3439
File {
3540
/// Input file (one number per line)
36-
#[structopt(parse(from_os_str))]
41+
#[arg(value_parser)]
3742
filename: PathBuf,
3843
},
44+
3945
/// Generate random floats in (0, 1]
4046
Random {
4147
/// Random generator to be used
42-
#[structopt(
48+
#[arg(
49+
value_enum,
4350
default_value = "uniform",
44-
parse(try_from_str),
45-
possible_values = RandomGen::variants()
51+
//possible_values = RandomGen::variants()
4652
)]
4753
gen: RandomGen,
54+
4855
/// Number of random floats generated
49-
#[structopt(short = "n", default_value = "50000")]
56+
#[arg(short = 'n', default_value = "50000")]
5057
count: usize,
58+
5159
/// Random generator seed
52-
#[structopt(short, default_value = "0")]
60+
#[arg(short, default_value = "0")]
5361
seed: u64,
62+
5463
/// Also save the generated inputs to file
55-
#[structopt(short = "f", parse(from_os_str))]
64+
#[arg(value_parser, short = 'f')]
5665
filename: Option<PathBuf>,
5766
},
67+
5868
/// Run all benchmarks for fast-float only
5969
All {
6070
/// Number of random floats generated
61-
#[structopt(short = "n", default_value = "50000")]
71+
#[structopt(short = 'n', default_value = "50000")]
6272
count: usize,
73+
6374
/// Random generator seed
6475
#[structopt(short, default_value = "0")]
6576
seed: u64,
@@ -263,7 +274,7 @@ impl Input {
263274
}
264275

265276
fn main() {
266-
let opt: Opt = StructOpt::from_args();
277+
let opt = Opt::parse();
267278

268279
let methods = if !opt.only_fast_float && !matches!(&opt.command, &Cmd::All { .. }) {
269280
Method::all().into()

extras/simple-bench/src/random.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,6 @@ impl FromStr for RandomGen {
5050
}
5151

5252
impl RandomGen {
53-
pub fn variants() -> &'static [&'static str] {
54-
&[
55-
"uniform",
56-
"one_over_rand32",
57-
"simple_uniform32",
58-
"simple_int32",
59-
"int_e_int",
60-
"simple_int64",
61-
"bigint_int_dot_int",
62-
"big_ints",
63-
]
64-
}
65-
6653
pub fn all() -> &'static [Self] {
6754
&[
6855
Self::Uniform,

0 commit comments

Comments
 (0)