Skip to content

Commit

Permalink
Alternate between token reclaim and distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
sakridge authored and mvines committed Jul 23, 2018
1 parent ea21c7a commit b3f823d
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions src/bin/bench-tps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,13 @@ fn main() {
let clients: Vec<_> = (0..threads).map(|_| mk_client(&leader)).collect();

// generate and send transactions for the specified duration
let time = Duration::new(time_sec / 2, 0);
let mut now = Instant::now();
let time = Duration::new(time_sec, 0);
let now = Instant::now();
let mut reclaim_tokens_back_to_source_account = false;
while now.elapsed() < time {
// ping-pong between source and destination accounts for each loop iteration
// this seems to be faster than trying to determine the balance of individaul
// accounts
generate_and_send_txs(
&mut client,
&clients,
Expand All @@ -362,27 +366,9 @@ fn main() {
txs,
&mut last_id,
threads,
false,
);
}

println!("Get last ID...");
last_id = client.get_last_id();
println!("Got last ID {:?}", last_id);

now = Instant::now();
while now.elapsed() < time {
generate_and_send_txs(
&mut client,
&clients,
&id,
&keypairs,
&leader,
txs,
&mut last_id,
threads,
true,
reclaim_tokens_back_to_source_account,
);
reclaim_tokens_back_to_source_account = !reclaim_tokens_back_to_source_account;
}

// Stop the sampling threads so it will collect the stats
Expand Down Expand Up @@ -440,6 +426,10 @@ fn main() {
total_txs,
maxes.read().unwrap().len()
);
println!(
"\tAverage TPS: {}",
total_txs as f32 / duration_as_s(&now.elapsed())
);

// join the crdt client threads
for t in c_threads {
Expand Down

0 comments on commit b3f823d

Please sign in to comment.