add --skip-coeff-calc

This commit is contained in:
Youngjoon Lee 2024-08-23 16:13:56 +09:00
parent d8b6e058eb
commit 66eb6ee9d2
No known key found for this signature in database
GPG Key ID: 167546E2D1712F8C
2 changed files with 36 additions and 18 deletions

View File

@ -20,7 +20,7 @@ pub fn run_iteration(
out_sent_sequence_path: &str,
out_received_sequence_path_prefix: &str,
out_queue_data_msg_counts_path: &str,
out_ordering_coeff_path: &str,
out_ordering_coeff_path: Option<String>,
out_topology_path: &str,
) -> f32 {
// Ensure that all output files do not exist
@ -29,11 +29,13 @@ pub fn run_iteration(
out_sent_sequence_path,
out_received_sequence_path_prefix,
out_queue_data_msg_counts_path,
out_ordering_coeff_path,
out_topology_path,
] {
assert!(!Path::new(path).exists(), "File already exists: {path}");
}
if let Some(path) = &out_ordering_coeff_path {
assert!(!Path::new(path).exists(), "File already exists: {path}");
}
let (mut mixnodes, sender_peers_list) = if paramset.random_topology {
build_random_network(&paramset, seed, out_topology_path)
@ -188,20 +190,22 @@ pub fn run_iteration(
format!("{out_received_sequence_path_prefix}_unified.csv").as_str(),
);
}
// Calculate ordering coefficients and save them to a CSV file.
if paramset.queue_type != QueueType::NonMix {
if let Some(unified_recv_seq) = &unified_received_sequence {
let casual = sent_sequence.ordering_coefficient(unified_recv_seq, true);
let weak = sent_sequence.ordering_coefficient(unified_recv_seq, false);
save_ordering_coefficients(&[[casual, weak]], out_ordering_coeff_path);
} else {
let mut coeffs: Vec<[u64; 2]> = Vec::new();
for recv_seq in received_sequences.iter() {
let casual = sent_sequence.ordering_coefficient(recv_seq, true);
let weak = sent_sequence.ordering_coefficient(recv_seq, false);
coeffs.push([casual, weak]);
// Calculate ordering coefficients and save them to a CSV file (if enabled)
if let Some(out_ordering_coeff_path) = &out_ordering_coeff_path {
if paramset.queue_type != QueueType::NonMix {
if let Some(unified_recv_seq) = &unified_received_sequence {
let casual = sent_sequence.ordering_coefficient(unified_recv_seq, true);
let weak = sent_sequence.ordering_coefficient(unified_recv_seq, false);
save_ordering_coefficients(&[[casual, weak]], out_ordering_coeff_path);
} else {
let mut coeffs: Vec<[u64; 2]> = Vec::new();
for recv_seq in received_sequences.iter() {
let casual = sent_sequence.ordering_coefficient(recv_seq, true);
let weak = sent_sequence.ordering_coefficient(recv_seq, false);
coeffs.push([casual, weak]);
}
save_ordering_coefficients(&coeffs, out_ordering_coeff_path);
}
save_ordering_coefficients(&coeffs, out_ordering_coeff_path);
}
}

View File

@ -25,6 +25,8 @@ struct Args {
queue_type: QueueType,
#[arg(short, long)]
outdir: String,
#[arg(short, long, default_value_t = false)]
skip_coeff_calc: bool,
#[arg(short, long)]
from_paramset: Option<u16>,
#[arg(short, long)]
@ -41,6 +43,7 @@ fn main() {
session_id,
queue_type,
outdir,
skip_coeff_calc,
from_paramset,
to_paramset,
} = args;
@ -95,14 +98,19 @@ fn main() {
&format!("{paramset_dir}/iteration_{i}_sent_seq.csv"),
&format!("{paramset_dir}/iteration_{i}_recv_seq"),
&wip_queue_data_msgs_counts_path,
&format!("{paramset_dir}/iteration_{i}_ordering_coeff.csv"),
if !skip_coeff_calc {
Some(format!("{paramset_dir}/iteration_{i}_ordering_coeff.csv"))
} else {
None
},
&format!("{paramset_dir}/iteration_{i}_topology.csv"),
);
let duration = SystemTime::now().duration_since(start_time).unwrap();
let duration_human = format_duration(duration);
dur_writer
.write_record([
i.to_string(),
format_duration(duration),
duration_human.clone(),
duration.as_secs().to_string(),
vtime.to_string(),
])
@ -112,7 +120,13 @@ fn main() {
wip_queue_data_msgs_counts_path.replace("__WIP__iteration_", "iteration_");
std::fs::rename(&wip_queue_data_msgs_counts_path, &new_queue_data_msgs_counts_path).expect("Failed to rename {wip_queue_data_msgs_counts_path} -> {new_queue_data_msgs_counts_path}: {e}");
tracing::info!("ParamSet:{}, Iteration:{} completed.", paramset.id, i);
tracing::info!(
"ParamSet:{}, Iteration:{} completed. Duration:{}, vtime:{}",
paramset.id,
i,
duration_human,
vtime
);
}
dur_writer.flush().unwrap();