File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,21 @@ use gluon::{
1010} ;
1111
1212// Benchmarks function calls
13+
14+ fn identity ( b : & mut Bencher ) {
15+ let vm = new_vm ( ) ;
16+ let text = r#"
17+ let id x = x
18+ id
19+ "# ;
20+ vm. load_script ( "id" , text) . unwrap ( ) ;
21+ let mut id: FunctionRef < fn ( i32 ) -> i32 > = vm. get_global ( "id" ) . unwrap ( ) ;
22+ b. iter ( || {
23+ let result = id. call ( 20 ) . unwrap ( ) ;
24+ black_box ( result)
25+ } )
26+ }
27+
1328fn factorial ( b : & mut Bencher ) {
1429 let vm = new_vm ( ) ;
1530 let text = r#"
@@ -81,6 +96,7 @@ fn gluon_rust_boundary_overhead(b: &mut Bencher) {
8196}
8297
8398fn function_call_benchmark ( c : & mut Criterion ) {
99+ c. bench_function ( "identity" , identity) ;
84100 c. bench_function ( "factorial" , factorial) ;
85101 c. bench_function ( "factorial tail call" , factorial_tail_call) ;
86102 c. bench_function ( "gluon rust boundary overhead" , gluon_rust_boundary_overhead) ;
You can’t perform that action at this time.
0 commit comments