Skip to content

Commit

Permalink
Broke loop when test is done
Browse files Browse the repository at this point in the history
  • Loading branch information
emilpriver committed Sep 17, 2023
1 parent 359a345 commit 27ee77e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "benchmarker"
name = "elton"
version = "0.1.0"
edition = "2021"

Expand Down
11 changes: 4 additions & 7 deletions src/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ use tokio::{

use crate::routes;

/**
* TODO:
- Report back to main thread the result of test
*/

#[derive(Debug)]
pub struct Result {
pub connection_id: u64,
Expand Down Expand Up @@ -99,9 +94,11 @@ pub async fn run_benchmark(test: routes::CreateTest) -> Vec<Result> {
}

while let Some(i) = rx.recv().await {
println!("{:?}", i);
// TODO: break this
results.push(i);

if results.len() >= (test.connections * test.seconds) as usize {
break;
}
}

results
Expand Down
4 changes: 3 additions & 1 deletion src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ pub async fn create_test(
.unwrap();

tokio::spawn(async move {
benchmark::run_benchmark(payload.clone()).await;
let result = benchmark::run_benchmark(payload.clone()).await;
//TODO: store result in db
println!("{:?}", result);
});

HttpResponse::Created().json(test)
Expand Down

0 comments on commit 27ee77e

Please sign in to comment.