Skip to content

Commit

Permalink
ci(bench): flat sampling mode used for long-running benchmarks (rooch…
Browse files Browse the repository at this point in the history
…-network#1567)

* ci(bench): flat sampling mode used for long-running benchmarks

Keep the iteration count the same for all samples, saving time.

Official documents: https://bheisler.github.io/criterion.rs/book/user_guide/advanced_configuration.html
  • Loading branch information
popcnt1 authored Apr 13, 2024
1 parent 99d197f commit e2c3bbd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/rooch-benchmarks/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use bitcoincore_rpc_json::bitcoin::Block;
use coerce::actor::scheduler::timer::Timer;
use coerce::actor::system::ActorSystem;
use coerce::actor::IntoActor;
use criterion::Criterion;
use criterion::{Criterion, SamplingMode};
use lazy_static::lazy_static;
use moveos_config::store_config::RocksdbConfig;
use moveos_config::DataDirPath;
Expand Down Expand Up @@ -361,6 +361,8 @@ pub fn create_btc_blk_tx(height: u64, block_file: String) -> Result<L1BlockWithB

// pure execution, no validate, sequence
pub fn tx_exec_benchmark(c: &mut Criterion) {
let mut group = c.benchmark_group("flat-sampling-example");
group.sampling_mode(SamplingMode::Flat);
let mut binding_test =
binding_test::RustBindingTest::new_with_mode((*IMPORT_MODE).to_num()).unwrap();
let keystore = InMemKeystore::new_insecure_for_tests(10);
Expand Down Expand Up @@ -412,10 +414,11 @@ pub fn tx_exec_benchmark(c: &mut Criterion) {

let mut transactions_iter = transactions.into_iter().cycle();

c.bench_function(bench_id, |b| {
group.bench_function(bench_id, |b| {
b.iter(|| {
let tx = transactions_iter.next().unwrap();
binding_test.execute_verified_tx(tx.clone()).unwrap()
});
});
group.finish();
}

0 comments on commit e2c3bbd

Please sign in to comment.