Skip to content

Conversation

@SimonRastikian
Copy link
Contributor

This PR adds the analysis for the size of data sent over the wire in each of the different scheme protocols.

Closes #140 #134

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.80%. Comparing base (a745950) to head (bdecd53).

Files with missing lines Patch % Lines
src/test_utils/participant_simulation.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           simon/flexibility-in-bench     #241      +/-   ##
==============================================================
- Coverage                       87.83%   87.80%   -0.03%     
==============================================================
  Files                              50       50              
  Lines                            9757     9760       +3     
  Branches                         9757     9760       +3     
==============================================================
  Hits                             8570     8570              
- Misses                            737      740       +3     
  Partials                          450      450              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@gilcu3 gilcu3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't not figure if we are measuring the number of bytes sent by the participant being simulated. If we are not, we should certainly add it.

The rest looks good to me, except that we should use a proper crate instead of calculating statistics manually. I added a suggestion.


#[allow(clippy::cast_precision_loss)]
/// Analyzes the size of the received data by a participant accross the entire protocol
/// # Panics
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we discussed in a previous PR, we should not need this "Panics" annotation in benchmarking code, we can make it a global exception, as benchmarking code panicking is not a problem (in the same sense as tests)

Comment on lines +70 to +93
let min = *sizes.iter().min().expect("Minimum should exist");
let max = *sizes.iter().max().expect("Maximum should exist");
let avg = sizes.iter().sum::<usize>() as f64 / sizes.len() as f64;

// median
sizes.sort_unstable();
let mid = sizes.len() / 2;
let median = if sizes.len() % 2 == 0 {
(sizes[mid - 1] as f64 + sizes[mid] as f64) / 2.0
} else {
sizes[mid] as f64
};

// variance & standard deviation
let mean = sizes.iter().sum::<usize>() as f64 / sizes.len() as f64;
let squared_sum = sizes
.iter()
.map(|v| {
let diff = *v as f64 - mean;
diff * diff
})
.sum::<f64>();
let variance = squared_sum / sizes.len() as f64;
let std_dev = variance.sqrt();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can use a proper crate for all of this. I recommend using the statrs crate, like:

use statrs::statistics::Median;
use statrs::statistics::Data;

let x = [];
let x = Data::new(x);
assert!(x.median().is_nan());

let y = [0.0, 3.0, -2.0];
let y = Data::new(y);
assert_eq!(y.median(), 0.0);

Comment on lines +33 to +35
pub fn get_size(&self) -> usize {
self.view.iter().map(|(_, s)| s.len()).sum()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a more descriptive name for this, the size of a Simulator is pretty hard to guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Benchmark] [Robust-ECDSA] Generic Robust-Based ECDSA Benchmark Issue [Benchmark] [OT-ECDSA] Generic OT-Based ECDSA Benchmark Issue

4 participants