Skip to content

Commit

Permalink
More meaningfull global output
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeling committed Sep 24, 2024
1 parent 539d489 commit b3633a4
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 140 deletions.
45 changes: 45 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'databroker-perf'",
"cargo": {
"args": [
"build",
"--bin=databroker-perf",
"--package=databroker-perf"
],
"filter": {
"name": "databroker-perf",
"kind": "bin"
}
},
"args": ["--api", "kuksa.val.v2", "--run-seconds", "5", "--skip-seconds", "2", "--config", "configs/config_group_10.json"],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'databroker-perf'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=databroker-perf",
"--package=databroker-perf"
],
"filter": {
"name": "databroker-perf",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Options:
--host <HOST> Host address of databroker [default: http://127.0.0.1]
--port <PORT> Port of databroker [default: 55555]
--skip-seconds <ITERATIONS> Seconds to run (skip) before measuring the latency [default: 4]
--detail-output Print more details in the summary result
--detailed-output Print more details in the summary result
--config <FILE> Path to configuration file
--run-forever Run the measurements forever (until receiving a shutdown signal)
-v, --verbosity <LEVEL> Verbosity level. Can be one of ERROR, WARN, INFO, DEBUG, TRACE [default: WARN]
Expand Down Expand Up @@ -134,7 +134,7 @@ Group: Frame C | Cycle time(ms): 30
For a detailed output of the results, please enable the corresponding flag like:

```
./target/release/databroker-perf --detail-output
./target/release/databroker-perf --detailed-output
```

## Group config file
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct Args {
#[clap(
long,
display_order = 5,
value_name = "ITERATIONS",
value_name = "RUN_SECONDS",
default_value_t = 4
)]
skip_seconds: u64,
Expand All @@ -67,18 +67,18 @@ struct Args {
value_name = "Detailed ouput result",
default_value_t = false
)]
detail_output: bool,
detailed_output: bool,

/// Path to configuration file
#[clap(long = "config", display_order = 7, value_name = "FILE")]
config_file: Option<String>,
/// Path to test data file
#[clap(long = "test-data-file", display_order = 7, value_name = "FILE")]
test_data_file: Option<String>,

/// Run the measurements forever (until receiving a shutdown signal).
#[clap(
long,
action = clap::ArgAction::SetTrue,
display_order = 8,
conflicts_with = "seconds",
conflicts_with = "run_seconds",
default_value_t = false
)]
run_forever: bool,
Expand Down Expand Up @@ -117,7 +117,7 @@ async fn main() -> Result<()> {
api = Api::KuksaValV2;
}

let config_groups = read_config(args.config_file.as_ref())?;
let config_groups = read_config(args.test_data_file.as_ref())?;

// Skip at most _iterations_ number of iterations
let skip_seconds = max(0, min(args.run_seconds, args.skip_seconds));
Expand All @@ -130,7 +130,7 @@ async fn main() -> Result<()> {
skip_seconds,
api,
run_forever: args.run_forever,
detail_output: args.detail_output,
detailed_output: args.detailed_output,
};

perform_measurement(measurement_config, config_groups, shutdown_handler).await?;
Expand Down
56 changes: 24 additions & 32 deletions src/measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::config::{Group, Signal};

use crate::shutdown::ShutdownHandler;
use crate::subscriber::{self, Subscriber};
use crate::utils::write_output;
use crate::utils::{write_global_output, write_output};
use anyhow::{Context, Result};
use hdrhistogram::Histogram;
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
Expand Down Expand Up @@ -55,7 +55,7 @@ pub struct MeasurementConfig {
pub skip_seconds: u64,
pub api: Api,
pub run_forever: bool,
pub detail_output: bool,
pub detailed_output: bool,
}

pub struct MeasurementContext {
Expand All @@ -73,7 +73,7 @@ pub struct MeasurementContext {
pub struct MeasurementResult {
pub measurement_context: MeasurementContext,
pub iterations_executed: u64,
pub iterations_skipped: u64,
pub signals_skipped: u64,
pub start_time: SystemTime,
}

Expand Down Expand Up @@ -111,12 +111,14 @@ fn create_databroker_endpoint(host: String, port: u64) -> Result<Endpoint> {

let endpoint = tonic::transport::Channel::from_shared(databroker_address.clone())
.with_context(|| "Failed to parse server url")?;
let endpoint = endpoint
.initial_stream_window_size(1000 * 3 * 128 * 1024) // 20 MB stream window size
.initial_connection_window_size(1000 * 3 * 128 * 1024) // 20 MB connection window size
.keep_alive_timeout(Duration::from_secs(1)) // 60 seconds keepalive time
.keep_alive_timeout(Duration::from_secs(1)) // 20 seconds keepalive timeout
.timeout(Duration::from_secs(1));

// Leave out for now until we decide what and how to configure it
// let endpoint = endpoint
// .initial_stream_window_size(1000 * 3 * 128 * 1024) // 20 MB stream window size
// .initial_connection_window_size(1000 * 3 * 128 * 1024) // 20 MB connection window size
// .keep_alive_timeout(Duration::from_secs(1)) // 60 seconds keepalive time
// .keep_alive_timeout(Duration::from_secs(1)) // 20 seconds keepalive timeout
// .timeout(Duration::from_secs(1));

Ok(endpoint)
}
Expand Down Expand Up @@ -226,15 +228,15 @@ pub async fn perform_measurement(
};

tasks.spawn(async move {
let (iterations_executed, iterations_skipped) =
let (iterations_executed, signals_skipped) =
measurement_loop(&mut measurement_context).await.unwrap();

measurement_context.progress.finish();

Ok(MeasurementResult {
measurement_context,
iterations_executed,
iterations_skipped,
signals_skipped,
start_time,
})
});
Expand Down Expand Up @@ -267,27 +269,17 @@ pub async fn perform_measurement(
}
}

print!("\n\nSummary:");
print!("\n API: {}", measurement_config.api);
if measurement_config.run_forever {
print!("\n Run forever: Activated");
} else {
print!(
"\n Run seconds: {}",
measurement_config.run_seconds
);
}
print!(
"\n Skipped run seconds: {}",
measurement_config.skip_seconds
);

for group in config_groups {
let measurement_result = measurements_results
.iter()
.find(|result| result.measurement_context.group_name == group.group_name)
.unwrap();
write_output(measurement_result).unwrap();
let _ = write_global_output(&measurement_config, &measurements_results);

if measurement_config.detailed_output {
for group in config_groups {
let measurement_result = measurements_results
.iter()
.find(|result| result.measurement_context.group_name == group.group_name)
.unwrap();

write_output(measurement_result).unwrap();
}
}
Ok(())
}
Expand Down
Loading

0 comments on commit b3633a4

Please sign in to comment.