@@ -139,7 +139,7 @@ fn bench_host_to_wasm<Params, Results>(
139
139
{
140
140
// Benchmark the "typed" version, which should be faster than the versions
141
141
// below.
142
- c. bench_function ( & format ! ( "core - host-to-wasm - typed - {}" , name ) , |b| {
142
+ c. bench_function ( & format ! ( "core - host-to-wasm - typed - {name}" ) , |b| {
143
143
let typed = instance
144
144
. get_typed_func :: < Params , Results > ( & mut * store, name)
145
145
. unwrap ( ) ;
@@ -155,7 +155,7 @@ fn bench_host_to_wasm<Params, Results>(
155
155
156
156
// Benchmark the "untyped" version which should be the slowest of the three
157
157
// here, but not unduly slow.
158
- c. bench_function ( & format ! ( "core - host-to-wasm - untyped - {}" , name ) , |b| {
158
+ c. bench_function ( & format ! ( "core - host-to-wasm - untyped - {name}" ) , |b| {
159
159
let untyped = instance. get_func ( & mut * store, name) . unwrap ( ) ;
160
160
let params = typed_params. to_vals ( ) ;
161
161
let expected_results = typed_results. to_vals ( ) ;
@@ -180,28 +180,25 @@ fn bench_host_to_wasm<Params, Results>(
180
180
181
181
// Benchmark the "unchecked" version which should be between the above two,
182
182
// but is unsafe.
183
- c. bench_function (
184
- & format ! ( "core - host-to-wasm - unchecked - {}" , name) ,
185
- |b| {
186
- let untyped = instance. get_func ( & mut * store, name) . unwrap ( ) ;
187
- let params = typed_params. to_vals ( ) ;
188
- let results = typed_results. to_vals ( ) ;
189
- let mut space = vec ! [ ValRaw :: i32 ( 0 ) ; params. len( ) . max( results. len( ) ) ] ;
190
- b. iter ( || unsafe {
191
- for ( i, param) in params. iter ( ) . enumerate ( ) {
192
- space[ i] = param. to_raw ( & mut * store) . unwrap ( ) ;
193
- }
194
- untyped
195
- . call_unchecked ( & mut * store, space. as_mut_ptr ( ) , space. len ( ) )
196
- . unwrap ( ) ;
197
- for ( i, expected) in results. iter ( ) . enumerate ( ) {
198
- let ty = expected. ty ( & store) . unwrap ( ) ;
199
- let actual = Val :: from_raw ( & mut * store, space[ i] , ty) ;
200
- assert_vals_eq ( expected, & actual) ;
201
- }
202
- } )
203
- } ,
204
- ) ;
183
+ c. bench_function ( & format ! ( "core - host-to-wasm - unchecked - {name}" ) , |b| {
184
+ let untyped = instance. get_func ( & mut * store, name) . unwrap ( ) ;
185
+ let params = typed_params. to_vals ( ) ;
186
+ let results = typed_results. to_vals ( ) ;
187
+ let mut space = vec ! [ ValRaw :: i32 ( 0 ) ; params. len( ) . max( results. len( ) ) ] ;
188
+ b. iter ( || unsafe {
189
+ for ( i, param) in params. iter ( ) . enumerate ( ) {
190
+ space[ i] = param. to_raw ( & mut * store) . unwrap ( ) ;
191
+ }
192
+ untyped
193
+ . call_unchecked ( & mut * store, space. as_mut_ptr ( ) , space. len ( ) )
194
+ . unwrap ( ) ;
195
+ for ( i, expected) in results. iter ( ) . enumerate ( ) {
196
+ let ty = expected. ty ( & store) . unwrap ( ) ;
197
+ let actual = Val :: from_raw ( & mut * store, space[ i] , ty) ;
198
+ assert_vals_eq ( expected, & actual) ;
199
+ }
200
+ } )
201
+ } ) ;
205
202
}
206
203
207
204
/// Benchmarks the overhead of calling the host from WebAssembly itself
@@ -398,7 +395,7 @@ fn wasm_to_host(c: &mut Criterion) {
398
395
desc : & str ,
399
396
is_async : IsAsync ,
400
397
) {
401
- group. bench_function ( & format ! ( "core - wasm-to-host - {} - nop" , desc ) , |b| {
398
+ group. bench_function ( & format ! ( "core - wasm-to-host - {desc } - nop" ) , |b| {
402
399
let run = instance
403
400
. get_typed_func :: < u64 , ( ) > ( & mut * store, "run-nop" )
404
401
. unwrap ( ) ;
@@ -413,7 +410,7 @@ fn wasm_to_host(c: &mut Criterion) {
413
410
} )
414
411
} ) ;
415
412
group. bench_function (
416
- & format ! ( "core - wasm-to-host - {} - nop-params-and-results" , desc ) ,
413
+ & format ! ( "core - wasm-to-host - {desc } - nop-params-and-results" ) ,
417
414
|b| {
418
415
let run = instance
419
416
. get_typed_func :: < u64 , ( ) > ( & mut * store, "run-nop-params-and-results" )
@@ -636,31 +633,28 @@ mod component {
636
633
+ Sync ,
637
634
{
638
635
// Benchmark the "typed" version.
639
- c. bench_function (
640
- & format ! ( "component - host-to-wasm - typed - {}" , name) ,
641
- |b| {
642
- let typed = instance
643
- . get_typed_func :: < Params , Results > ( & mut * store, name)
644
- . unwrap ( ) ;
645
- b. iter ( || {
646
- let results = if is_async. use_async ( ) {
647
- run_await ( typed. call_async ( & mut * store, typed_params) ) . unwrap ( )
648
- } else {
649
- typed. call ( & mut * store, typed_params) . unwrap ( )
650
- } ;
651
- assert_eq ! ( results, typed_results) ;
652
- if is_async. use_async ( ) {
653
- run_await ( typed. post_return_async ( & mut * store) ) . unwrap ( )
654
- } else {
655
- typed. post_return ( & mut * store) . unwrap ( )
656
- }
657
- } )
658
- } ,
659
- ) ;
636
+ c. bench_function ( & format ! ( "component - host-to-wasm - typed - {name}" ) , |b| {
637
+ let typed = instance
638
+ . get_typed_func :: < Params , Results > ( & mut * store, name)
639
+ . unwrap ( ) ;
640
+ b. iter ( || {
641
+ let results = if is_async. use_async ( ) {
642
+ run_await ( typed. call_async ( & mut * store, typed_params) ) . unwrap ( )
643
+ } else {
644
+ typed. call ( & mut * store, typed_params) . unwrap ( )
645
+ } ;
646
+ assert_eq ! ( results, typed_results) ;
647
+ if is_async. use_async ( ) {
648
+ run_await ( typed. post_return_async ( & mut * store) ) . unwrap ( )
649
+ } else {
650
+ typed. post_return ( & mut * store) . unwrap ( )
651
+ }
652
+ } )
653
+ } ) ;
660
654
661
655
// Benchmark the "untyped" version.
662
656
c. bench_function (
663
- & format ! ( "component - host-to-wasm - untyped - {}" , name ) ,
657
+ & format ! ( "component - host-to-wasm - untyped - {name}" ) ,
664
658
|b| {
665
659
let untyped = instance. get_func ( & mut * store, name) . unwrap ( ) ;
666
660
let params = typed_params. to_component_vals ( ) ;
@@ -864,7 +858,7 @@ mod component {
864
858
desc : & str ,
865
859
is_async : IsAsync ,
866
860
) {
867
- group. bench_function ( & format ! ( "component - wasm-to-host - {} - nop" , desc ) , |b| {
861
+ group. bench_function ( & format ! ( "component - wasm-to-host - {desc } - nop" ) , |b| {
868
862
let run = instance
869
863
. get_typed_func :: < ( u64 , ) , ( ) > ( & mut * store, "run-nop" )
870
864
. unwrap ( ) ;
@@ -881,10 +875,7 @@ mod component {
881
875
} )
882
876
} ) ;
883
877
group. bench_function (
884
- & format ! (
885
- "component - wasm-to-host - {} - nop-params-and-results" ,
886
- desc
887
- ) ,
878
+ & format ! ( "component - wasm-to-host - {desc} - nop-params-and-results" ) ,
888
879
|b| {
889
880
let run = instance
890
881
. get_typed_func :: < ( u64 , ) , ( ) > ( & mut * store, "run-nop-params-and-results" )
0 commit comments