@@ -2,8 +2,8 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion};
22
33use rand:: Rng ;
44use std:: sync:: Arc ;
5- use std:: thread;
65use std:: time:: { Duration , SystemTime } ;
6+ use std:: { fs, thread} ;
77use tempfile:: TempDir ;
88
99use cosmwasm_std:: { coins, Checksum , Empty } ;
@@ -34,6 +34,17 @@ const DEFAULT_CAPABILITIES: &str = "cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,itera
3434static HACKATOM : & [ u8 ] = include_bytes ! ( "../testdata/hackatom.wasm" ) ;
3535static CYBERPUNK : & [ u8 ] = include_bytes ! ( "../testdata/cyberpunk.wasm" ) ;
3636
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+
3748fn bench_instance ( c : & mut Criterion ) {
3849 let mut group = c. benchmark_group ( "Instance" ) ;
3950
@@ -169,16 +180,25 @@ fn bench_cache(c: &mut Criterion) {
169180 } ) ;
170181 } ) ;
171182
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 ( ) ;
173191 let cache: Cache < MockApi , MockStorage , MockQuerier > =
174192 unsafe { Cache :: new ( options. clone ( ) ) . unwrap ( ) } ;
175- let checksum = cache. save_wasm ( HACKATOM ) . unwrap ( ) ;
193+ let checksum = cache. save_wasm ( & contract_wasm ) . unwrap ( ) ;
176194
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+ } ) ;
180200 } ) ;
181- } ) ;
201+ }
182202
183203 group. bench_function ( "instantiate from fs" , |b| {
184204 let non_memcache = CacheOptions :: new (
0 commit comments