Skip to content

Commit fe386ee

Browse files
committed
bench: omit other crates in codspeed
1 parent c90c0ee commit fe386ee

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
tool: cargo-codspeed
4545

4646
- name: Build benchmark
47-
run: cargo codspeed build
47+
run: cargo codspeed build --features codspeed
4848

4949
- name: Run benchmark
5050
uses: CodSpeedHQ/action@v4

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ path = "examples/escape.rs"
1818

1919
[features]
2020
force_aarch64_neon = [] # Force use of neon implementation on aarch64
21+
codspeed = []
2122

2223
[[bench]]
2324
name = "escape"

benches/escape.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ fn run_benchmarks(c: &mut Criterion, sources: &[String], prefix: &str) {
4545
}
4646
})
4747
});
48+
#[cfg(not(feature = "codspeed"))]
4849
c.bench_function(&format!("{} escape v_jsonescape", prefix), |b| {
4950
b.iter(|| {
5051
for source in sources {
5152
black_box(v_jsonescape::escape(source).to_string());
5253
}
5354
})
5455
});
56+
#[cfg(not(feature = "codspeed"))]
5557
c.bench_function(&format!("{} json-escape", prefix), |b| {
5658
b.iter(|| {
5759
for source in sources {
@@ -66,6 +68,7 @@ fn run_benchmarks(c: &mut Criterion, sources: &[String], prefix: &str) {
6668
}
6769
})
6870
});
71+
#[cfg(not(feature = "codspeed"))]
6972
c.bench_function(&format!("{} serde_json", prefix), |b| {
7073
b.iter(|| {
7174
for source in sources {

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ pub use generic::{escape_generic, escape_into_generic};
119119
/// Main entry point for JSON string escaping with SIMD acceleration
120120
/// If the platform is supported, the SIMD path will be used. Otherwise, the generic fallback will be used.
121121
pub fn escape<S: AsRef<str>>(input: S) -> String {
122+
#[cfg(not(feature = "force_aarch64_neon"))]
122123
use generic::escape_inner;
123124

124125
let mut result = Vec::with_capacity(input.as_ref().len() + input.as_ref().len() / 2 + 2);
@@ -178,6 +179,7 @@ pub fn escape<S: AsRef<str>>(input: S) -> String {
178179
/// Main entry point for JSON string escaping with SIMD acceleration
179180
/// If the platform is supported, the SIMD path will be used. Otherwise, the generic fallback will be used.
180181
pub fn escape_into<S: AsRef<str>>(input: S, output: &mut Vec<u8>) {
182+
#[cfg(not(feature = "force_aarch64_neon"))]
181183
use generic::escape_inner;
182184

183185
output.push(b'"');
@@ -208,7 +210,7 @@ pub fn escape_into<S: AsRef<str>>(input: S, output: &mut Vec<u8>) {
208210
{
209211
#[cfg(feature = "force_aarch64_neon")]
210212
{
211-
return aarch64::escape_neon(bytes, output);
213+
aarch64::escape_neon(bytes, output);
212214
}
213215
#[cfg(not(feature = "force_aarch64_neon"))]
214216
{

0 commit comments

Comments
 (0)