@@ -5,30 +5,46 @@ use criterion::{black_box, Criterion, ParameterizedBenchmark};
5
5
6
6
fn empty_env ( c : & mut Criterion ) {
7
7
c. bench_function ( "call empty env" , |b| {
8
- b. iter ( || black_box ( topo:: call!( || topo:: Id :: current( ) ) ) )
8
+ b. iter ( || black_box ( topo:: call!( topo:: Id :: current( ) ) ) )
9
9
} ) ;
10
10
}
11
11
12
12
fn create_small_env ( c : & mut Criterion ) {
13
13
c. bench_function ( "call create small env" , |b| {
14
14
b. iter ( || {
15
- black_box ( topo:: call!( || topo:: Id :: current( ) , Env {
16
- u128 => 10
17
- } ) )
15
+ black_box ( topo:: call!(
16
+ topo:: Id :: current( ) ,
17
+ env! {
18
+ u128 => 10 ,
19
+ }
20
+ ) )
18
21
} ) ;
19
22
} ) ;
20
23
}
21
24
25
+ fn call_small_env ( c : & mut Criterion ) {
26
+ c. bench_function ( "call within small env" , |b| {
27
+ topo:: call!(
28
+ b. iter( || {
29
+ black_box( topo:: call!( topo:: Id :: current( ) ) ) ;
30
+ } ) ,
31
+ env! {
32
+ u128 => 10 ,
33
+ }
34
+ )
35
+ } ) ;
36
+ }
37
+
22
38
#[ allow( clippy:: trivially_copy_pass_by_ref) ]
23
39
fn topo_bench ( b : & mut criterion:: Bencher , depth : & usize ) {
24
40
macro_rules! mk {
25
41
( go $depth_spec: ident) => {
26
- topo:: call!( || {
42
+ topo:: call!( {
27
43
mk!( pass $depth_spec 0 ) ;
28
- } , Env { u128 => 10 } ) ;
44
+ } , env! { u128 => 10 , } ) ;
29
45
} ;
30
46
( pass $depth_spec: ident $call_depth: expr) => {
31
- topo:: call!( || {
47
+ topo:: call!( {
32
48
mk!( cur $depth_spec ( $call_depth + 1 ) ) ;
33
49
} ) ;
34
50
} ;
@@ -91,7 +107,7 @@ fn topo_bench(b: &mut criterion::Bencher, depth: &usize) {
91
107
}
92
108
}
93
109
94
- fn enter_small_env ( c : & mut Criterion ) {
110
+ fn from_small_env ( c : & mut Criterion ) {
95
111
c. bench (
96
112
"topo fns" ,
97
113
ParameterizedBenchmark :: new (
@@ -102,5 +118,11 @@ fn enter_small_env(c: &mut Criterion) {
102
118
) ;
103
119
}
104
120
105
- criterion_group ! ( benches, empty_env, create_small_env, enter_small_env) ;
106
- criterion_main ! ( benches) ;
121
+ criterion:: criterion_group!(
122
+ benches,
123
+ empty_env,
124
+ create_small_env,
125
+ from_small_env,
126
+ call_small_env
127
+ ) ;
128
+ criterion:: criterion_main!( benches) ;
0 commit comments