Skip to content

Commit

Permalink
Add num_blocks field to last_x_blocks_metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Angel-Petrov committed Feb 23, 2024
1 parent bed07cc commit 6c7edf8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,23 @@ At the end of all benchmarks gomu gomu will collect the results into a single js
- `all_bench_report`: A report over all benchmarks done

- `benches`: A array of reports for all benchmarks

- `name`: The name of the benchmark
- `amount`: How many times this benchmark was ran
- `metrics`: An array of benchmark metrics over the whole benchmark
- `metrics`: An array of metrics over the whole benchmark

- `name`: The name of the metric
- `unit`: The unit of the metric, empty when there is no unit
- `value`: The metrics value, a number

- For floats, `Infinite` and `NaN` are not JSON numbers and thus will be turned into `null`

- `last_x_blocks_metrics`: An array of benchmark metrics over the last metrics, changed by `num_blocks`
- `last_x_blocks_metrics`: Metrics over the last blocks of the benchmark

- `extra`: Extra information for this run
- `num_blocks`: The amount of last transactions that were measured
- `metrics`: An array of metrics

- `extra`: Extra information for this run

Gomu gomu will also display into the console information about each step in the benchmark.

Expand Down
22 changes: 15 additions & 7 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ pub struct BenchmarkReport {
pub amount: usize,
pub metrics: Vec<MetricResult>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_x_blocks_metrics: Option<Vec<MetricResult>>,
pub last_x_blocks_metrics: Option<LastXBlocksMetric>,
}

#[derive(Debug, Clone, Serialize)]
pub struct LastXBlocksMetric {
pub num_blocks: u64,
pub metrics: Vec<MetricResult>,
}

impl BenchmarkReport {
Expand Down Expand Up @@ -105,7 +111,10 @@ impl BenchmarkReport {
let num_tx_per_block = get_num_tx_per_block(starknet_rpc, start_block, end_block).await?;
let metrics = compute_node_metrics(num_tx_per_block).to_vec();

self.last_x_blocks_metrics = Some(metrics);
self.last_x_blocks_metrics = Some(LastXBlocksMetric {
num_blocks,
metrics,
});

Ok(())
}
Expand Down Expand Up @@ -179,7 +188,8 @@ impl BenchmarkReport {
MetricResult {
name: "Mean Verification Time",
unit: "milliseconds",
value: (verification_requests.raw_data.total_time as f64 / scenario.counter as f64).into(),
value: (verification_requests.raw_data.total_time as f64 / scenario.counter as f64)
.into(),
},
]);

Expand Down Expand Up @@ -211,11 +221,9 @@ impl fmt::Display for BenchmarkReport {
}

if let Some(last_x_blocks) = last_x_blocks {
let len = last_x_blocks.len();

writeln!(f, "Last {len} block metrics:")?;
writeln!(f, "Last {} block metrics:", last_x_blocks.num_blocks)?;

for metric in last_x_blocks {
for metric in &last_x_blocks.metrics {
writeln!(f, "{metric}")?;
}
}
Expand Down

0 comments on commit 6c7edf8

Please sign in to comment.