Skip to content

Commit 5943e9d

Browse files
authored
Merge pull request #20 from Alexhuszagh/audit
Add security audit to CI.
2 parents f36b3a6 + bc12fa0 commit 5943e9d

File tree

6 files changed

+203
-13
lines changed

6 files changed

+203
-13
lines changed

.github/workflows/audit.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Audit Dependencies"
2+
3+
on:
4+
push:
5+
paths:
6+
# Run if workflow changes
7+
- '.github/workflows/audit.yml'
8+
# Run on changed dependencies
9+
- '**/Cargo.toml'
10+
- '**/Cargo.lock'
11+
# Run if the configuration file changes
12+
- '**/audit.toml'
13+
schedule:
14+
# run weekly
15+
- cron: '0 0 * * 0'
16+
workflow_dispatch:
17+
18+
jobs:
19+
audit:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
issues: write
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: actions-rust-lang/audit@v1
27+
name: Audit Rust Dependencies

.github/workflows/bench.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Bench
2+
3+
# TODO: Change back to dispatch
4+
on:
5+
[push, pull_request, workflow_dispatch]
6+
7+
jobs:
8+
bench:
9+
name: Bench ${{matrix.os}}
10+
runs-on: ${{matrix.os}}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
- uses: dtolnay/rust-toolchain@stable
20+
21+
# VERSION/DIAGNOSTICS
22+
23+
- if: matrix.os == 'ubuntu-latest'
24+
name: Get Linux CPU Info
25+
run: cat /proc/cpuinfo
26+
shell: bash
27+
28+
- if: matrix.os == 'macos-latest'
29+
name: Get macOS CPU Info
30+
run: sysctl -a | grep cpu
31+
shell: bash
32+
33+
- if: matrix.os == 'windows-latest'
34+
name: Get Windows CPU Info
35+
run: wmic cpu list /format:list
36+
shell: bash
37+
38+
- run: cargo --version
39+
- run: cmake --version
40+
41+
# RUST
42+
43+
- run: |
44+
cd extras/simple-bench
45+
cargo build --release
46+
name: Build Rust
47+
48+
- run: |
49+
cd extras/simple-bench
50+
cargo run --release -- file ext/data/canada.txt
51+
cargo run --release -- file ext/data/mesh.txt
52+
cargo run --release -- random uniform
53+
cargo run --release -- random one_over_rand32
54+
cargo run --release -- random simple_uniform32
55+
cargo run --release -- random simple_int32
56+
cargo run --release -- random simple_int64
57+
cargo run --release -- random int_e_int
58+
cargo run --release -- random int_e_int
59+
cargo run --release -- random bigint_int_dot_int
60+
cargo run --release -- random big_ints
61+
name: Bench Rust
62+
shell: bash
63+
64+
# C++
65+
66+
- run: |
67+
cd extras/simple-bench/ext
68+
cmake -DCMAKE_BUILD_TYPE=Release -B build .
69+
cmake --build build --config Release
70+
name: Build C/C++
71+
72+
- run: |
73+
cd extras/simple-bench/ext
74+
if [[ -f build/benchmarks/Release/benchmark.exe ]]; then
75+
exe=build/benchmarks/Release/benchmark.exe
76+
else
77+
exe=build/benchmarks/benchmark
78+
fi
79+
"${exe}" -f data/canada.txt
80+
"${exe}" -f data/mesh.txt
81+
"${exe}" -m uniform
82+
"${exe}" -m one_over_rand32
83+
"${exe}" -m simple_uniform32
84+
"${exe}" -m simple_int32
85+
"${exe}" -m simple_int64
86+
"${exe}" -m int_e_int
87+
"${exe}" -m bigint_int_dot_int
88+
"${exe}" -m big_ints
89+
name: Bench C/C++
90+
shell: bash

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
matrix:
1313
rust: [1.63.0, stable, nightly]
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1616
with:
1717
submodules: recursive
1818
- uses: dtolnay/rust-toolchain@master

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: Lint
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1212
with:
1313
submodules: recursive
1414
- uses: dtolnay/rust-toolchain@master

README.md

Lines changed: 83 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,98 @@ C++ library, here are few brief notes:
104104

105105
## Benchmarks
106106

107-
Below are tables of best timings in nanoseconds for parsing a single number
108-
into a 64-bit float (using the median score).
107+
Below are tables of best timings in nanoseconds for parsing a single number into a 64-bit float (using the median score, lower is better).
109108

110-
### Intel i7-14700K
109+
<!--
110+
111+
Not all C++ benchmarks report ns/float, which we use for our benches.
112+
You can convert from MFloat/s to ns/float with:
113+
114+
```python
115+
mfloat_to_ns = lambda x: 1e9 / x / 1e6
116+
```
111117
112-
Intel i7-14700K 3.40GHz, Linux (WSL2), Rust 1.81.
118+
-->
113119

114-
| | `canada` | `mesh` | `uniform` | `bi` | `iei` | `rec32` |
115-
| ---------------------- | -------- | -------- | --------- | ----- | ------ | ------- |
116-
| fast-float2 | 9.98 | 5.56 | 10.08 | 56.19 | 14.52 | 15.09 |
117-
| fast-float | 9.77 | 5.04 | 9.05 | 57.52 | 14.40 | 14.23 |
118-
| lexical | 10.62 | 4.93 | 9.92 | 26.40 | 12.43 | 14.40 |
119-
| from_str | 11.59 | 5.92 | 11.23 | 35.92 | 14.75 | 16.76 |
120+
### Intel i7-14700K
121+
122+
- CPU: Intel i7-14700K 3.40GHz
123+
- OS: Ubuntu 24.04 (WSL2)
124+
- Rust: 1.81
125+
- C++: GCC 13.2.0
126+
127+
| | `canada` | `mesh` | `uniform` | `bi` | `iei` | `rec32` |
128+
| ---------------------- | -------- | -------- | --------- | ------ | ------ | ------- |
129+
| fast-float2 | 9.98 | 5.56 | 10.08 | 56.19 | 14.52 | 15.09 |
130+
| fast-float | 9.77 | 5.04 | 9.05 | 57.52 | 14.40 | 14.23 |
131+
| lexical | 10.62 | 4.93 | 9.92 | 26.40 | 12.43 | 14.40 |
132+
| from_str | 11.59 | 5.92 | 11.23 | 35.92 | 14.75 | 16.76 |
120133
| fast_float (C++) | 12.58 | 6.35 | 11.86 | 31.55 | 12.22 | 11.97 |
121134
| abseil (C++) | 25.32 | 15.70 | 25.88 | 43.42 | 23.54 | 26.75 |
122135
| netlib (C) | 35.10 | 10.22 | 37.72 | 68.63 | 23.07 | 38.23 |
123136
| strtod (C) | 52.63 | 26.47 | 46.51 | 88.11 | 33.37 | 53.36 |
124137
| doubleconversion (C++) | 32.50 | 14.69 | 47.80 | 70.01 | 205.72 | 45.66 |
125138

139+
### AMD EPYC 7763 64-Core Processor (Linux)
140+
141+
- CPU: AMD EPYC 7763 64-Core Processor 3.20GHz
142+
- OS: Ubuntu 24.04.1
143+
- Rust: 1.83
144+
- C++: GCC 13.2.0
145+
- Environment: Github Actions (2.321.0)
146+
147+
| | `canada` | `mesh` | `uniform` | `bi` | `iei` | `rec32` |
148+
| ---------------------- | -------- | -------- | --------- | ------ | ------ | ------- |
149+
| fast-float2 | 19.83 | 10.42 | 18.64 | 80.03 | 26.12 | 27.70 |
150+
| fast-float | 19.17 | 9.89 | 17.34 | 82.37 | 25.26 | 27.22 |
151+
| lexical | 18.89 | 8.41 | 16.83 | 47.66 | 22.08 | 26.99 |
152+
| from_str | 22.90 | 12.72 | 22.10 | 62.20 | 27.51 | 30.80 |
153+
| fast_float (C++) | 20.71 | 10.72 | 24.63 | 82.85 | 24.24 | 19.60 |
154+
| abseil (C++) | 31.03 | 23.78 | 32.82 | 76.05 | 28.41 | 35.03 |
155+
| netlib (C) | 54.22 | 20.12 | 68.68 | 82.64 | 32.81 | 69.43 |
156+
| strtod (C) | 100.10 | 52.08 | 85.32 | 192.31 | 75.08 | 97.85 |
157+
| doubleconversion (C++) | 75.13 | 31.98 | 87.64 | 170.06 | 124.69 | 87.26 |
158+
159+
### AMD EPYC 7763 64-Core Processor (Windows)
160+
161+
- CPU: AMD EPYC 7763 64-Core Processor 3.20GHz
162+
- OS: Windows Server 2022 (10.0.20348)
163+
- Rust: 1.83
164+
- C++: MSVC 19.42.34435.0
165+
- Environment: Github Actions (2.321.0)
166+
167+
| | `canada` | `mesh` | `uniform` | `bi` | `iei` | `rec32` |
168+
| ---------------------- | -------- | -------- | --------- | ------ | ------ | ------- |
169+
| fast-float2 | 20.92 | 10.02 | 19.34 | 94.37 | 27.09 | 30.84 |
170+
| fast-float | 19.72 | 9.65 | 18.46 | 86.85 | 25.75 | 30.05 |
171+
| lexical | 19.15 | 8.80 | 17.92 | 51.14 | 22.16 | 28.34 |
172+
| from_str | 25.93 | 13.49 | 23.36 | 78.82 | 27.80 | 35.58 |
173+
| fast_float (C++) | 64.89 | 47.46 | 64.40 | 104.36 | 55.44 | 69.29 |
174+
| abseil (C++) | 37.77 | 33.10 | 41.24 | 136.86 | 37.11 | 47.32 |
175+
| netlib (C) | 53.76 | 28.78 | 60.96 | 76.35 | 44.33 | 62.96 |
176+
| strtod (C) | 181.47 | 85.95 | 192.35 | 262.81 | 125.37 | 204.94 |
177+
| doubleconversion (C++) | 119.02 | 28.78 | 128.16 | 232.35 | 110.97 | 129.63 |
178+
179+
### Apple M1 (macOS)
180+
181+
- CPU: AMD EPYC 7763 64-Core Processor 3.20GHz
182+
- OS: macOS (14.7.1)
183+
- Rust: 1.83
184+
- C++: Clang (Apple) 15.0.0.15000309
185+
- Environment: Github Actions
186+
187+
| | `canada` | `mesh` | `uniform` | `bi` | `iei` | `rec32` |
188+
| ---------------------- | -------- | -------- | --------- | ------ | ------ | ------- |
189+
| fast-float2 | 15.47 | 6.54 | 11.62 | 94.35 | 20.55 | 17.78 |
190+
| fast-float | 14.56 | 6.40 | 11.09 | 92.89 | 21.19 | 17.06 |
191+
| lexical | 14.13 | 6.55 | 11.96 | 35.99 | 15.93 | 18.91 |
192+
| from_str | 17.67 | 7.93 | 13.88 | 58.60 | 19.68 | 19.92 |
193+
| fast_float (C++) | 17.42 | 10.40 | 15.14 | 87.33 | 21.82 | 14.53 |
194+
| abseil (C++) | 20.94 | 17.31 | 22.50 | 63.86 | 24.69 | 25.19 |
195+
| netlib (C) | 45.05 | 13.79 | 52.38 | 156.25 | 36.10 | 51.36 |
196+
| strtod (C) | 25.88 | 14.25 | 27.08 | 85.32 | 23.03 | 26.86 |
197+
| doubleconversion (C++) | 53.39 | 21.50 | 73.15 | 120.63 | 52.88 | 70.47 |
198+
126199
Note that the random number generation seems to differ between C/C++ and Rust, since the Rust implementations are slightly faster for pre-determined datasets like `canada` and `mesh`, but equivalent random number generators are slightly slower. Any performance penalty with `fast-float2` occurred due to fixing the UB in [check_len](https://github.com/aldanor/fast-float-rust/issues/28). The massive performance differences between `fast-float` (Rust) and `fast_float` (C++) are expected due to a faster fallback algorithms ([#96](https://github.com/fastfloat/fast_float/pull/96) and [#104](https://github.com/fastfloat/fast_float/pull/104)) used in these cases.
127200

128201
#### Parsers

0 commit comments

Comments
 (0)