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 3131 - name : print cpu features
3232 run : |
3333 rustup toolchain install nightly
34- cargo +nightly run --example cpu_features
34+ cargo +nightly run -p cpu-features --features nightly
3535 - name : Run benchmarks
3636 run : cargo test
3737
Original file line number Diff line number Diff line change @@ -2,20 +2,20 @@ use std::hint::black_box;
22
33use criterion:: { Criterion , criterion_group, criterion_main} ;
44
5- use string_escape_simd :: { encode_str , encode_str_fallback } ;
5+ use json_escape_simd :: { escape , escape_generic } ;
66
77const FIXTURE : & str = include_str ! ( "../cal.com.tsx" ) ;
88
99fn 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 ) ) ) ) ;
1111 c. bench_function ( "escape v_jsonescape" , |b| {
1212 b. iter ( || black_box ( v_jsonescape:: escape ( FIXTURE ) . to_string ( ) ) )
1313 } ) ;
1414 c. bench_function ( "json-escape" , |b| {
1515 b. iter ( || black_box ( json_escape:: escape_str ( FIXTURE ) . collect :: < String > ( ) ) )
1616 } ) ;
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 ) ) )
1919 } ) ;
2020 c. bench_function ( "serde_json" , |b| {
2121 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 } ;
22
33fn main ( ) {
44 let fixture = include_str ! ( "../cal.com.tsx" ) ;
55 let encoded = escape ( fixture) ;
6- let encoded_fallback = encode_str_fallback ( fixture) ;
6+ let encoded_fallback = escape_generic ( fixture) ;
77 assert_eq ! ( encoded, encoded_fallback) ;
88}
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ macro_rules! tri {
7070}
7171
7272#[ inline]
73- pub fn encode_str_fallback < S : AsRef < str > > ( input : S ) -> String {
73+ pub fn escape_generic < S : AsRef < str > > ( input : S ) -> String {
7474 let s = input. as_ref ( ) ;
7575 let bytes = s. as_bytes ( ) ;
7676
@@ -145,7 +145,7 @@ pub fn escape<S: AsRef<str>>(input: S) -> String {
145145 }
146146
147147 // Fallback to optimized scalar implementation
148- encode_str_fallback ( input)
148+ escape_generic ( input)
149149}
150150
151151#[ test]
You can’t perform that action at this time.
0 commit comments