randomize tx ordering (#4978)
Summary of Changes: This change adds functionality to randomize tx execution for every entry. It does this by implementing OrderedIterator that iterates tx slice as per the order specified. The order is generated randomly for every entry.
This commit is contained in:
19
runtime/benches/transaction_utils.rs
Normal file
19
runtime/benches/transaction_utils.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
#![feature(test)]
|
||||
|
||||
extern crate test;
|
||||
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::thread_rng;
|
||||
use solana_runtime::transaction_utils::OrderedIterator;
|
||||
use test::Bencher;
|
||||
|
||||
#[bench]
|
||||
fn bench_ordered_iterator_with_order_shuffling(bencher: &mut Bencher) {
|
||||
let vec: Vec<usize> = (0..100_usize).collect();
|
||||
bencher.iter(|| {
|
||||
let mut order: Vec<usize> = (0..100_usize).collect();
|
||||
order.shuffle(&mut thread_rng());
|
||||
let _ordered_iterator_resp: Vec<&usize> =
|
||||
OrderedIterator::new(&vec, Some(&order)).collect();
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user