This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
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.
- Loading branch information
Showing
5 changed files
with
87 additions
and
17 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
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,4 +1,4 @@ | ||
use std::io::stdin; | ||
use std::{io::stdin, time::Instant}; | ||
|
||
use clap::{arg, command}; | ||
use producer::Producer; | ||
|
@@ -20,15 +20,75 @@ fn main() -> Result<(), String> { | |
|
||
println!("Broker details: {:#?}", producer.broker_details); | ||
|
||
println!("Broadcasting a test message to the partition"); | ||
println!("Broadcasting messages..."); | ||
|
||
Broadcast::to( | ||
&mut producer.stream, | ||
&shared_structures::Message::ProducerMessage { | ||
replica_id: producer.destination_replica_id, | ||
payload: json!({"message": "test"}), | ||
}, | ||
)?; | ||
let total_itteration = 50_000; | ||
|
||
let mut message_count = 0; | ||
|
||
let start_time = Instant::now(); | ||
|
||
// ---------------------- Just for a test ------------------------- | ||
loop { | ||
if message_count == total_itteration { | ||
break; | ||
} | ||
|
||
Broadcast::to( | ||
&mut producer.stream, | ||
&shared_structures::Message::ProducerMessage { | ||
replica_id: producer.destination_replica_id.clone(), | ||
payload: json!({ | ||
"_meta": { | ||
"template_version": 0 | ||
}, | ||
"fixtures": [ | ||
{ | ||
"name": "cus_jenny_rosen", | ||
"path": "/v1/customers", | ||
"method": "post", | ||
"params": { | ||
"name": "Jenny Rosen", | ||
"email": "[email protected]", | ||
"source": "tok_visa", | ||
"address": { | ||
"line1": "1 Main Street", | ||
"city": "New York" | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "ch_jenny_charge", | ||
"path": "/v1/charges", | ||
"method": "post", | ||
"params": { | ||
"customer": "${cus_jenny_rosen:id}", | ||
"amount": 100, | ||
"currency": "usd", | ||
"capture": false | ||
} | ||
}, | ||
{ | ||
"name": "capt_bender", | ||
"path": "/v1/charges/${ch_jenny_charge:id}/capture", | ||
"method": "post" | ||
} | ||
] | ||
}), | ||
}, | ||
)?; | ||
message_count += 1; | ||
} | ||
// ---------------------------------------------------------------- | ||
|
||
let end_time = Instant::now(); | ||
let elapsed_time = end_time - start_time; | ||
|
||
let executions_per_second = (total_itteration as f64) / (elapsed_time.as_secs_f64()); | ||
|
||
println!("Total message: {:?}", total_itteration); | ||
println!("Total time: {:?}", elapsed_time); | ||
println!("Executions per second: {:.2}", executions_per_second); | ||
|
||
let mut buf = String::with_capacity(1024); | ||
|
||
|
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