@@ -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,19 @@ fn bench_cache(c: &mut Criterion) {
169
180
} ) ;
170
181
} ) ;
171
182
172
- group. bench_function ( "analyze" , |b| {
183
+ for contract_name in BENCH_CONTRACTS {
184
+ let contract_wasm = fs:: read ( format ! ( "testdata/{contract_name}" ) ) . unwrap ( ) ;
173
185
let cache: Cache < MockApi , MockStorage , MockQuerier > =
174
186
unsafe { Cache :: new ( options. clone ( ) ) . unwrap ( ) } ;
175
- let checksum = cache. save_wasm ( HACKATOM ) . unwrap ( ) ;
187
+ let checksum = cache. save_wasm ( & contract_wasm ) . unwrap ( ) ;
176
188
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
+ } ) ;
180
194
} ) ;
181
- } ) ;
195
+ }
182
196
183
197
group. bench_function ( "instantiate from fs" , |b| {
184
198
let non_memcache = CacheOptions :: new (
0 commit comments