-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
171d8fc
commit e584c4e
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod mev_boost; | ||
pub mod roothash; | ||
pub mod txpool_fetcher; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use criterion::{criterion_group, Criterion}; | ||
use eth_sparse_mpt::reth_sparse_trie::SparseTrieSharedCache; | ||
use rbuilder::roothash::{calculate_state_root, RootHashConfig}; | ||
use reth_provider::{test_utils::create_test_provider_factory, ExecutionOutcome}; | ||
use revm_primitives::B256; | ||
|
||
async fn calculate_state_root_util(use_sparse_trie: bool, compare_sparse_trie_output: bool) { | ||
let provider = create_test_provider_factory(); | ||
|
||
let _ = calculate_state_root( | ||
provider, | ||
B256::default(), | ||
&ExecutionOutcome::default(), | ||
SparseTrieSharedCache::default(), | ||
RootHashConfig::live_config(use_sparse_trie, compare_sparse_trie_output), | ||
); | ||
} | ||
|
||
fn bench_calculate_state_root(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("Roothash calculator"); | ||
let rt = tokio::runtime::Runtime::new().unwrap(); | ||
|
||
group.bench_function( | ||
"calculate_state_root_use_sparse_trie_compare_sparse_trie_output", | ||
|b| { | ||
b.to_async(&rt) | ||
.iter(|| calculate_state_root_util(true, true)); | ||
}, | ||
); | ||
group.bench_function("calculate_state_root_use_sparse_trie", |b| { | ||
b.to_async(&rt) | ||
.iter(|| calculate_state_root_util(true, false)); | ||
}); | ||
group.bench_function("calculate_state_root_compare_sparse_trie_output", |b| { | ||
b.to_async(&rt) | ||
.iter(|| calculate_state_root_util(false, true)); | ||
}); | ||
group.bench_function("calculate_state_root", |b| { | ||
b.to_async(&rt) | ||
.iter(|| calculate_state_root_util(false, false)); | ||
}); | ||
} | ||
|
||
criterion_group!(roothash, bench_calculate_state_root); |