mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(net): make benchmark inputs deterministic (#13563)
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
#![allow(missing_docs)]
|
||||
use alloy_primitives::U256;
|
||||
use alloy_primitives::{
|
||||
private::proptest::test_runner::{RngAlgorithm, TestRng},
|
||||
U256,
|
||||
};
|
||||
use criterion::*;
|
||||
use futures::StreamExt;
|
||||
use pprof::criterion::{Output, PProfProfiler};
|
||||
use rand::thread_rng;
|
||||
use reth_network::{test_utils::Testnet, NetworkEventListenerProvider};
|
||||
use reth_network_api::Peers;
|
||||
use reth_provider::test_utils::{ExtendedAccount, MockEthProvider};
|
||||
@ -49,7 +51,9 @@ pub fn broadcast_ingress_bench(c: &mut Criterion) {
|
||||
}
|
||||
|
||||
// prepare some transactions
|
||||
let mut gen = TransactionGenerator::new(thread_rng());
|
||||
let mut gen = TransactionGenerator::new(TestRng::deterministic_rng(
|
||||
RngAlgorithm::ChaCha,
|
||||
));
|
||||
let num_broadcasts = 10;
|
||||
for _ in 0..num_broadcasts {
|
||||
for _ in 0..2 {
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
#![allow(missing_docs)]
|
||||
use alloy_primitives::U256;
|
||||
|
||||
use alloy_primitives::{
|
||||
private::proptest::test_runner::{RngAlgorithm, TestRng},
|
||||
U256,
|
||||
};
|
||||
use criterion::*;
|
||||
use pprof::criterion::{Output, PProfProfiler};
|
||||
use rand::thread_rng;
|
||||
use reth_network::{
|
||||
test_utils::Testnet,
|
||||
transactions::{
|
||||
@ -61,7 +64,10 @@ pub fn tx_fetch_bench(c: &mut Criterion) {
|
||||
let peer_pool = peer.pool().unwrap();
|
||||
|
||||
for _ in 0..num_tx_per_peer {
|
||||
let mut gen = TransactionGenerator::new(thread_rng());
|
||||
let mut gen = TransactionGenerator::new(
|
||||
TestRng::deterministic_rng(RngAlgorithm::ChaCha),
|
||||
);
|
||||
|
||||
let tx = gen.gen_eip1559_pooled();
|
||||
let sender = tx.sender();
|
||||
provider.add_account(
|
||||
|
||||
Reference in New Issue
Block a user