mirror of
https://github.com/logos-blockchain/logos-blockchain-simulations.git
synced 2026-01-11 01:23:09 +00:00
add more columns to iteration result csv files
This commit is contained in:
parent
8bfbabed15
commit
aebc0459b5
@ -45,6 +45,7 @@ class Simulation:
|
||||
with open(out_csv_path, "w", newline="", buffering=8192) as f:
|
||||
# Use CSV writer which is less error-prone than manually writing rows to the file
|
||||
writer = csv.writer(f)
|
||||
writer.writerow(["dissemination_time", "sent_time", "all_received_time"])
|
||||
# To count how many nodes have received each message
|
||||
received_msg_counters: Counter[bytes] = Counter()
|
||||
# To count how many results (dissemination time) have been collected so far
|
||||
@ -56,11 +57,12 @@ class Simulation:
|
||||
# If the message has been received by all nodes, calculate the dissemination time.
|
||||
received_msg_counters.update([msg])
|
||||
if received_msg_counters[msg] == len(nodes):
|
||||
dissemination_time = (
|
||||
received_time - Message.from_bytes(msg).sent_time
|
||||
)
|
||||
sent_time = Message.from_bytes(msg).sent_time
|
||||
dissemination_time = received_time - sent_time
|
||||
# Use repr to convert a float to a string with as much precision as Python can provide
|
||||
writer.writerow([repr(dissemination_time)])
|
||||
writer.writerow(
|
||||
[repr(dissemination_time), repr(sent_time), repr(received_time)]
|
||||
)
|
||||
result_cnt += 1
|
||||
|
||||
def __run_nodes(self) -> list[Node]:
|
||||
|
||||
@ -44,8 +44,9 @@ def __calculate_paramset_stats(paramset_dir: str, session_result_path: str):
|
||||
|
||||
series_list = []
|
||||
for iter_csv in glob.glob(f"{paramset_dir}/iteration_*.csv"):
|
||||
df = pd.read_csv(iter_csv, header=None)
|
||||
series_list.append(pd.Series(df.squeeze()))
|
||||
df = pd.read_csv(iter_csv)
|
||||
# The 1st column is the dissemination time
|
||||
series_list.append(pd.Series(df.iloc[:, 0]))
|
||||
|
||||
series = pd.concat(series_list, ignore_index=True)
|
||||
stats = series.describe()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user