@@ -17,34 +17,26 @@ limitations under the License.
17
17
// Benchmarks are only meaningful and should only run with optimized builds.
18
18
// Unoptimized builds have different performance characteristics and would not provide
19
19
// useful benchmarking data for performance regression testing.
20
+ #![ cfg( optimized_build) ]
20
21
21
- #[ cfg( optimized_build) ]
22
22
use criterion:: { Criterion , criterion_group, criterion_main} ;
23
- #[ cfg( optimized_build) ]
24
23
use hyperlight_host:: GuestBinary ;
25
- #[ cfg( optimized_build) ]
26
24
use hyperlight_host:: sandbox:: {
27
25
Callable , MultiUseSandbox , SandboxConfiguration , UninitializedSandbox ,
28
26
} ;
29
- #[ cfg( optimized_build) ]
30
27
use hyperlight_host:: sandbox_state:: sandbox:: EvolvableSandbox ;
31
- #[ cfg( optimized_build) ]
32
28
use hyperlight_host:: sandbox_state:: transition:: Noop ;
33
- #[ cfg( optimized_build) ]
34
29
use hyperlight_testing:: simple_guest_as_string;
35
30
36
- #[ cfg( optimized_build) ]
37
31
fn create_uninit_sandbox ( ) -> UninitializedSandbox {
38
32
let path = simple_guest_as_string ( ) . unwrap ( ) ;
39
33
UninitializedSandbox :: new ( GuestBinary :: FilePath ( path) , None ) . unwrap ( )
40
34
}
41
35
42
- #[ cfg( optimized_build) ]
43
36
fn create_multiuse_sandbox ( ) -> MultiUseSandbox {
44
37
create_uninit_sandbox ( ) . evolve ( Noop :: default ( ) ) . unwrap ( )
45
38
}
46
39
47
- #[ cfg( optimized_build) ]
48
40
fn guest_call_benchmark ( c : & mut Criterion ) {
49
41
let mut group = c. benchmark_group ( "guest_functions" ) ;
50
42
@@ -92,7 +84,6 @@ fn guest_call_benchmark(c: &mut Criterion) {
92
84
group. finish ( ) ;
93
85
}
94
86
95
- #[ cfg( optimized_build) ]
96
87
fn guest_call_benchmark_large_param ( c : & mut Criterion ) {
97
88
let mut group = c. benchmark_group ( "guest_functions_with_large_parameters" ) ;
98
89
#[ cfg( target_os = "windows" ) ]
@@ -128,7 +119,6 @@ fn guest_call_benchmark_large_param(c: &mut Criterion) {
128
119
group. finish ( ) ;
129
120
}
130
121
131
- #[ cfg( optimized_build) ]
132
122
fn sandbox_benchmark ( c : & mut Criterion ) {
133
123
let mut group = c. benchmark_group ( "sandboxes" ) ;
134
124
@@ -168,19 +158,10 @@ fn sandbox_benchmark(c: &mut Criterion) {
168
158
group. finish ( ) ;
169
159
}
170
160
171
- #[ cfg( optimized_build) ]
172
161
criterion_group ! {
173
162
name = benches;
174
163
config = Criterion :: default ( ) ;
175
164
targets = guest_call_benchmark, sandbox_benchmark, guest_call_benchmark_large_param
176
165
}
177
166
178
- #[ cfg( optimized_build) ]
179
167
criterion_main ! ( benches) ;
180
-
181
- // For unoptimized builds, provide a minimal main function that explains benchmarks are not available
182
- #[ cfg( unoptimized_build) ]
183
- fn main ( ) {
184
- eprintln ! ( "Benchmarks are only available in optimized builds. Use `cargo bench --release` or `just bench`." ) ;
185
- std:: process:: exit ( 1 ) ;
186
- }
0 commit comments