Skip to content

Commit

Permalink
Refactor benchmark output handling and add JSON/HTML support
Browse files Browse the repository at this point in the history
This commit refactors the benchmark output handling by replacing CSV and TOML
file generation with JSON and HTML outputs. The `output_directory` argument is
replaced with `output`, and the results are now serialized into a JSON file.
Additionally, HTML plots are generated using the `charming` library, providing
a visual representation of throughput and latency over time.

- Removed CSV and TOML dependencies and related code.
- Added `charming` and `serde_json` dependencies for JSON and HTML output.
- Updated scripts to reflect changes in output handling.
- Improved directory handling in performance scripts.
  • Loading branch information
hubcio committed Jan 8, 2025
1 parent 00f66ea commit d6ca8eb
Show file tree
Hide file tree
Showing 22 changed files with 953 additions and 167 deletions.
102 changes: 80 additions & 22 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ edition = "2021"

[dependencies]
async-trait = "0.1.84"
charming = "0.4.0"
chrono = "0.4.31"
clap = { version = "4.5.23", features = ["derive"] }
colored = "2.2.0"
csv = "1.3.1"
derive-new = "0.7.0"
derive_more = "1.0.0"
figlet-rs = "0.1.5"
Expand All @@ -17,6 +18,8 @@ iggy = { path = "../sdk" }
integration = { path = "../integration" }
nonzero_lit = "0.1.2"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.114"
sysinfo = "0.33.1"
tokio = { version = "1.42.0", features = ["full"] }
toml = "0.8.19"
tracing = { version = "0.1.41" }
Expand Down
13 changes: 5 additions & 8 deletions bench/src/args/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ pub struct IggyBenchArgs {
#[arg(long, short = 'k', default_value_t = DEFAULT_SKIP_SERVER_START)]
pub skip_server_start: bool,

/// Output directory, in which the benchmark results will be stored as `csv` and `toml` files.
/// Sample from the benchmark will be stored in a `csv` file on per-actor manner - each
/// producer/consumer will have its own file.
/// Actor summary, benchmark summary and parameters will be stored in a TOML file.
#[arg(long, short = 'o', default_value = None)]
pub output_directory: Option<String>,
/// Output directory path for the benchmark results
#[arg(long, short)]
pub output: Option<String>,
}

fn validate_server_executable_path(v: &str) -> Result<String, String> {
Expand Down Expand Up @@ -141,7 +138,7 @@ impl IggyBenchArgs {
self.warmup_time
}

pub fn output_directory(&self) -> Option<String> {
self.output_directory.clone()
pub fn output(&self) -> Option<String> {
self.output.clone()
}
}
3 changes: 2 additions & 1 deletion bench/src/args/simple.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use derive_more::Display;
use serde::Serialize;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display, Serialize)]
pub enum BenchmarkKind {
#[display("send messages")]
Send,
Expand Down
48 changes: 20 additions & 28 deletions bench/src/benchmark_params.rs
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
use std::io::Write;

use crate::args::common::IggyBenchArgs;
use chrono::{DateTime, Utc};
use iggy::utils::timestamp::IggyTimestamp;
use serde::Serialize;

#[derive(Debug, Serialize)]
pub struct BenchmarkParams {
timestamp_micros: i64,
benchmark_name: String,
transport: String,
messages_per_batch: u32,
message_batches: u32,
message_size: u32,
producers: u32,
consumers: u32,
streams: u32,
partitions: u32,
number_of_consumer_groups: u32,
disable_parallel_consumers: bool,
disable_parallel_producers: bool,
}

impl BenchmarkParams {
pub fn dump_to_toml(&self, output_directory: &str) {
let output_file = format!("{}/params.toml", output_directory);
let toml_str = toml::to_string(self).unwrap();
Write::write_all(
&mut std::fs::File::create(output_file).unwrap(),
toml_str.as_bytes(),
)
.unwrap();
}
pub timestamp: String,
pub benchmark_name: String,
pub transport: String,
pub messages_per_batch: u32,
pub message_batches: u32,
pub message_size: u32,
pub producers: u32,
pub consumers: u32,
pub streams: u32,
pub partitions: u32,
pub number_of_consumer_groups: u32,
pub disable_parallel_consumers: bool,
pub disable_parallel_producers: bool,
}

impl From<&IggyBenchArgs> for BenchmarkParams {
fn from(args: &IggyBenchArgs) -> Self {
let timestamp =
DateTime::<Utc>::from_timestamp_micros(IggyTimestamp::now().as_micros() as i64)
.map(|dt| dt.to_rfc3339())
.unwrap_or_else(|| String::from("unknown"));

BenchmarkParams {
timestamp_micros: IggyTimestamp::now().as_micros() as i64,
timestamp,
benchmark_name: args.benchmark_kind.as_simple_kind().to_string(),
transport: args.transport().to_string(),
messages_per_batch: args.messages_per_batch(),
Expand Down
Loading

0 comments on commit d6ca8eb

Please sign in to comment.