Skip to content

Commit 98fda11

Browse files
committed
Add cpu features detection
1 parent 5b9a02a commit 98fda11

File tree

9 files changed

+678
-91
lines changed

9 files changed

+678
-91
lines changed

.github/workflows/CI.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ jobs:
2828
uses: dtolnay/rust-toolchain@stable
2929
with:
3030
targets: ${{ matrix.settings.target }}
31+
- name: print cpu features
32+
run: |
33+
rustup toolchain install nightly
34+
cargo +nightly run --example cpu_features
3135
- name: Run benchmarks
3236
run: cargo test
3337

@@ -39,6 +43,10 @@ jobs:
3943
os: ubuntu-latest
4044
- target: x86_64-pc-windows-msvc
4145
os: windows-latest
46+
- target: aarch64-unknown-linux-gnu
47+
os: ubuntu-24.04-arm
48+
- target: aarch64-apple-darwin
49+
os: macos-latest
4250
fail-fast: false
4351
runs-on: ${{ matrix.settings.os }}
4452
steps:

Cargo.lock

Lines changed: 26 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
[workspace]
2+
members = ["cpu-features"]
3+
14
[package]
2-
name = "string-escape-simd"
5+
name = "json-escape-simd"
36
version = "0.1.0"
4-
edition = "2021"
5-
6-
[features]
7-
nightly = [] # For benchmark
8-
default = []
7+
edition = "2024"
8+
rust-version = "1.89.0"
99

1010
[[example]]
1111
name = "escape"
@@ -22,6 +22,7 @@ anyhow = "1"
2222
criterion = { version = "0.7", features = ["html_reports"] }
2323
serde_json = "1"
2424
v_jsonescape = "0.7"
25+
json-escape = "0.1.1"
2526

2627
[profile.bench]
2728
lto = true
@@ -30,4 +31,4 @@ codegen-units = 1
3031
[profile.instruments]
3132
inherits = "release"
3233
lto = false
33-
debug = true
34+
debug = true

benches/escape.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::hint::black_box;
22

3-
use criterion::{criterion_group, criterion_main, Criterion};
3+
use criterion::{Criterion, criterion_group, criterion_main};
44

55
use string_escape_simd::{encode_str, encode_str_fallback};
66

@@ -11,9 +11,15 @@ fn criterion_benchmark(c: &mut Criterion) {
1111
c.bench_function("escape v_jsonescape", |b| {
1212
b.iter(|| black_box(v_jsonescape::escape(FIXTURE).to_string()))
1313
});
14+
c.bench_function("json-escape", |b| {
15+
b.iter(|| black_box(json_escape::escape_str(FIXTURE).collect::<String>()))
16+
});
1417
c.bench_function("escape software", |b| {
1518
b.iter(|| black_box(encode_str_fallback(FIXTURE)))
1619
});
20+
c.bench_function("serde_json", |b| {
21+
b.iter(|| black_box(serde_json::to_string(FIXTURE).unwrap()))
22+
});
1723
}
1824

1925
criterion_group!(benches, criterion_benchmark);

cpu-features/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "cpu-features"
3+
version = "0.1.0"
4+
edition = "2024"
5+
rust-version = "1.89.0"
6+
7+
[features]
8+
nightly = []

0 commit comments

Comments
 (0)