mirror of
https://github.com/logos-blockchain/logos-blockchain-simulations.git
synced 2026-02-18 04:03:06 +00:00
add --skip-coeff-calc
This commit is contained in:
parent
d8b6e058eb
commit
66eb6ee9d2
@ -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(¶mset, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user