Flag Skew Threshold

This commit is contained in:
Sarah Jamie Lewis 2021-02-01 12:20:30 -08:00
parent af21afb297
commit 0f940e5bab
2 changed files with 3 additions and 3 deletions

View File

@ -9,7 +9,7 @@ mod server;
use clap::Clap;
#[derive(Clap)]
#[clap(version = "1.0", author = "Sarah Jamie Lewis <sarah@opneprivacy.ca>")]
#[clap(version = "1.0", author = "Sarah Jamie Lewis <sarah@openprivacy.ca>")]
struct Opts {
/// Sets a custom config file. Could have been an Option<T> with no default too
#[clap(short, long, default_value = "24")]
@ -51,7 +51,7 @@ fn main() {
let round_statistics = server.statistics();
let mut stdout = StandardStream::stdout(ColorChoice::Always);
for (party, stats) in round_statistics.iter() {
if stats.trivial_breaks > 0 {
if stats.trivial_breaks > 0 || stats.observed_skew > 10.0 {
stdout.set_color(ColorSpec::new().set_fg(Some(Color::Red))).unwrap();
} else {
stdout.set_color(ColorSpec::new().set_fg(Some(Color::Green))).unwrap();

View File

@ -58,7 +58,7 @@ impl SimulatedServer {
let observed_rate = (observed_messages as f64) / (self.messages.len() as f64);
let expected_messages = ideal_rate * (self.messages.len() as f64);
let observed_skew_messages = expected_messages - (observed_messages as f64);
let observed_skew = observed_rate / ideal_rate;
let observed_skew = (observed_messages as f64) / expected_messages;
let mut trivial_breaks = 0;
for tag in matched.iter() {