File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 31
31
- name : print cpu features
32
32
run : |
33
33
rustup toolchain install nightly
34
- cargo +nightly run --example cpu_features
34
+ cargo +nightly run -p cpu-features --features nightly
35
35
- name : Run benchmarks
36
36
run : cargo test
37
37
Original file line number Diff line number Diff line change @@ -2,20 +2,20 @@ use std::hint::black_box;
2
2
3
3
use criterion:: { Criterion , criterion_group, criterion_main} ;
4
4
5
- use string_escape_simd :: { encode_str , encode_str_fallback } ;
5
+ use json_escape_simd :: { escape , escape_generic } ;
6
6
7
7
const FIXTURE : & str = include_str ! ( "../cal.com.tsx" ) ;
8
8
9
9
fn criterion_benchmark ( c : & mut Criterion ) {
10
- c. bench_function ( "escape simd" , |b| b. iter ( || black_box ( encode_str ( FIXTURE ) ) ) ) ;
10
+ c. bench_function ( "escape simd" , |b| b. iter ( || black_box ( escape ( FIXTURE ) ) ) ) ;
11
11
c. bench_function ( "escape v_jsonescape" , |b| {
12
12
b. iter ( || black_box ( v_jsonescape:: escape ( FIXTURE ) . to_string ( ) ) )
13
13
} ) ;
14
14
c. bench_function ( "json-escape" , |b| {
15
15
b. iter ( || black_box ( json_escape:: escape_str ( FIXTURE ) . collect :: < String > ( ) ) )
16
16
} ) ;
17
- c. bench_function ( "escape software " , |b| {
18
- b. iter ( || black_box ( encode_str_fallback ( FIXTURE ) ) )
17
+ c. bench_function ( "escape generic " , |b| {
18
+ b. iter ( || black_box ( escape_generic ( FIXTURE ) ) )
19
19
} ) ;
20
20
c. bench_function ( "serde_json" , |b| {
21
21
b. iter ( || black_box ( serde_json:: to_string ( FIXTURE ) . unwrap ( ) ) )
Original file line number Diff line number Diff line change 1
- use json_escape_simd:: { encode_str_fallback , escape } ;
1
+ use json_escape_simd:: { escape , escape_generic } ;
2
2
3
3
fn main ( ) {
4
4
let fixture = include_str ! ( "../cal.com.tsx" ) ;
5
5
let encoded = escape ( fixture) ;
6
- let encoded_fallback = encode_str_fallback ( fixture) ;
6
+ let encoded_fallback = escape_generic ( fixture) ;
7
7
assert_eq ! ( encoded, encoded_fallback) ;
8
8
}
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ macro_rules! tri {
70
70
}
71
71
72
72
#[ inline]
73
- pub fn encode_str_fallback < S : AsRef < str > > ( input : S ) -> String {
73
+ pub fn escape_generic < S : AsRef < str > > ( input : S ) -> String {
74
74
let s = input. as_ref ( ) ;
75
75
let bytes = s. as_bytes ( ) ;
76
76
@@ -145,7 +145,7 @@ pub fn escape<S: AsRef<str>>(input: S) -> String {
145
145
}
146
146
147
147
// Fallback to optimized scalar implementation
148
- encode_str_fallback ( input)
148
+ escape_generic ( input)
149
149
}
150
150
151
151
#[ test]
You can’t perform that action at this time.
0 commit comments