@@ -2,8 +2,8 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion};
2
2
3
3
use rand:: Rng ;
4
4
use std:: sync:: Arc ;
5
- use std:: thread;
6
5
use std:: time:: { Duration , SystemTime } ;
6
+ use std:: { fs, thread} ;
7
7
use tempfile:: TempDir ;
8
8
9
9
use cosmwasm_std:: { coins, Checksum , Empty } ;
@@ -34,6 +34,17 @@ const DEFAULT_CAPABILITIES: &str = "cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,itera
34
34
static HACKATOM : & [ u8 ] = include_bytes ! ( "../testdata/hackatom.wasm" ) ;
35
35
static CYBERPUNK : & [ u8 ] = include_bytes ! ( "../testdata/cyberpunk.wasm" ) ;
36
36
37
+ static BENCH_CONTRACTS : & [ & str ] = & [
38
+ "cyberpunk_rust170.wasm" ,
39
+ "cyberpunk.wasm" ,
40
+ "floaty_1.0.wasm" ,
41
+ "floaty_1.2.wasm" ,
42
+ "floaty_2.0.wasm" ,
43
+ "hackatom_1.0.wasm" ,
44
+ "hackatom_1.2.wasm" ,
45
+ "hackatom.wasm" ,
46
+ ] ;
47
+
37
48
fn bench_instance ( c : & mut Criterion ) {
38
49
let mut group = c. benchmark_group ( "Instance" ) ;
39
50
@@ -169,16 +180,25 @@ fn bench_cache(c: &mut Criterion) {
169
180
} ) ;
170
181
} ) ;
171
182
172
- group. bench_function ( "analyze" , |b| {
183
+ let path_iter = glob:: glob ( "testdata/*.wasm" ) . unwrap ( ) . flat_map ( Result :: ok) ;
184
+ for contract_path in path_iter {
185
+ let contract_name = contract_path. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
186
+ if !BENCH_CONTRACTS . contains ( & contract_name) {
187
+ continue ;
188
+ }
189
+
190
+ let contract_wasm = fs:: read ( & contract_path) . unwrap ( ) ;
173
191
let cache: Cache < MockApi , MockStorage , MockQuerier > =
174
192
unsafe { Cache :: new ( options. clone ( ) ) . unwrap ( ) } ;
175
- let checksum = cache. save_wasm ( HACKATOM ) . unwrap ( ) ;
193
+ let checksum = cache. save_wasm ( & contract_wasm ) . unwrap ( ) ;
176
194
177
- b. iter ( || {
178
- let result = cache. analyze ( & checksum) ;
179
- assert ! ( result. is_ok( ) ) ;
195
+ group. bench_function ( format ! ( "analyze_{contract_name}" ) , |b| {
196
+ b. iter ( || {
197
+ let result = cache. analyze ( & checksum) ;
198
+ assert ! ( result. is_ok( ) ) ;
199
+ } ) ;
180
200
} ) ;
181
- } ) ;
201
+ }
182
202
183
203
group. bench_function ( "instantiate from fs" , |b| {
184
204
let non_memcache = CacheOptions :: new (
0 commit comments