forked from kaspanet/rusty-kaspa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-picked Optimized Rothschild performance on high TPS (kaspanet#371
- Loading branch information
1 parent
7aec7bb
commit 45fcb58
Showing
11 changed files
with
284 additions
and
70 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,50 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use rayon::prelude::*; | ||
|
||
use kash_consensus_core::asset_type::AssetType::KSH; | ||
use kash_consensus_core::tx::TransactionAction::TransferKSH; | ||
use kash_consensus_core::{ | ||
constants::TX_VERSION, | ||
subnets::SUBNETWORK_ID_NATIVE, | ||
tx::{ScriptPublicKey, Transaction, TransactionInput, TransactionOutpoint, TransactionOutput}, | ||
Hash, | ||
}; | ||
|
||
fn constuct_tx() -> Transaction { | ||
let inputs = vec![TransactionInput { | ||
previous_outpoint: TransactionOutpoint { transaction_id: Hash::from_bytes([0xFF; 32]), index: 0 }, | ||
signature_script: vec![], | ||
sequence: 0, | ||
sig_op_count: 1, | ||
}]; | ||
let outputs = | ||
vec![TransactionOutput { value: 10000, asset_type: KSH, script_public_key: ScriptPublicKey::from_vec(0, vec![0xff; 35]) }]; | ||
Transaction::new(TX_VERSION, inputs, outputs, TransferKSH, 0, SUBNETWORK_ID_NATIVE, 0, vec![]) | ||
} | ||
|
||
fn construct_txs_serially() { | ||
let _ = (0..10000) | ||
.map(|_| { | ||
constuct_tx(); | ||
}) | ||
.collect::<Vec<_>>(); | ||
} | ||
|
||
fn construct_txs_parallel() { | ||
let _ = (0..10000) | ||
.into_par_iter() | ||
.map(|_| { | ||
constuct_tx(); | ||
}) | ||
.collect::<Vec<_>>(); | ||
} | ||
|
||
pub fn bench_compare_tx_generation(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("compare txs"); | ||
group.bench_function("Transaction::SerialCreation", |b| b.iter(construct_txs_serially)); | ||
group.bench_function("Transaction::ParallelCreation", |b| b.iter(construct_txs_parallel)); | ||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches, bench_compare_tx_generation); | ||
criterion_main!(benches); |
Oops, something went wrong.