@@ -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,19 @@ fn bench_cache(c: &mut Criterion) {
169180 } ) ;
170181 } ) ;
171182
172- group. bench_function ( "analyze" , |b| {
183+ for contract_name in BENCH_CONTRACTS {
184+ let contract_wasm = fs:: read ( format ! ( "testdata/{contract_name}" ) ) . unwrap ( ) ;
173185 let cache: Cache < MockApi , MockStorage , MockQuerier > =
174186 unsafe { Cache :: new ( options. clone ( ) ) . unwrap ( ) } ;
175- let checksum = cache. save_wasm ( HACKATOM ) . unwrap ( ) ;
187+ let checksum = cache. save_wasm ( & contract_wasm ) . unwrap ( ) ;
176188
177- b. iter ( || {
178- let result = cache. analyze ( & checksum) ;
179- assert ! ( result. is_ok( ) ) ;
189+ group. bench_function ( format ! ( "analyze_{contract_name}" ) , |b| {
190+ b. iter ( || {
191+ let result = cache. analyze ( & checksum) ;
192+ assert ! ( result. is_ok( ) ) ;
193+ } ) ;
180194 } ) ;
181- } ) ;
195+ }
182196
183197 group. bench_function ( "instantiate from fs" , |b| {
184198 let non_memcache = CacheOptions :: new (
0 commit comments