rtl measure

main
RangeOfGlitching 3 years ago
parent 5399e5cf7f
commit 8d8a6fbbc4

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

@ -0,0 +1,13 @@
from pathlib import Path
# Get the path to the directory to traverse
directory = Path.cwd()
Protodir = []
Jsondir = []
# Iterate over the files and directories in the directory tree
for path in directory.glob('**/*.log'):
if "Proto" in str(path):
Protodir.append(path)
elif "Json" in str(path):
Jsondir.append(path)
print(Protodir)

@ -0,0 +1,55 @@
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import argparse
numberOfMsg = 1000
def checkNumberofLines(df):
if df.shape[0] != numberOfMsg:
raise Exception("Number of lines in the log file is not correct")
else:
return True
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-q", "--qos", type=int, default=0, help="qos", required=True)
parser.add_argument("-b", "--broker", type=str, default="{}", help="Broker", required=True)
args = parser.parse_args()
# read in the log file
df_Proto_delayA_PUB = pd.read_csv(f"{args.broker}/qos{args.qos}/ProtodelayA_PUB.log", delim_whitespace=True, header=None, names=["count", "time"])
df_Proto_delayA_SUB = pd.read_csv(f"{args.broker}/qos{args.qos}/ProtodelayA_SUB.log", delim_whitespace=True, header=None, names=["count", "time"])
df_Proto_delayB_SUB = pd.read_csv(f"{args.broker}/qos{args.qos}/ProtodelayB_SUB.log", delim_whitespace=True, header=None, names=["count", "time"])
df_Json_delayA_PUB = pd.read_csv(f"{args.broker}/qos{args.qos}/JsondelayA_PUB.log", delim_whitespace=True, header=None, names=["count", "time"])
df_Json_delayA_SUB = pd.read_csv(f"{args.broker}/qos{args.qos}/JsondelayA_SUB.log", delim_whitespace=True, header=None, names=["count", "time"])
df_Json_delayB_SUB = pd.read_csv(f"{args.broker}/qos{args.qos}/JsondelayB_SUB.log", delim_whitespace=True, header=None, names=["count", "time"])
# check if the number of lines is correct
checkNumberofLines(df_Proto_delayA_PUB)
checkNumberofLines(df_Proto_delayA_SUB)
checkNumberofLines(df_Proto_delayB_SUB)
checkNumberofLines(df_Json_delayA_PUB)
checkNumberofLines(df_Json_delayA_SUB)
checkNumberofLines(df_Json_delayB_SUB)
# print the resulting DataFrame
diff_Proto_df = pd.DataFrame({"Difftime":(df_Proto_delayA_SUB["time"] - df_Proto_delayA_PUB["time"] - df_Proto_delayB_SUB["time"])/1e9})
diff_Json_df = pd.DataFrame({"Difftime":(df_Json_delayA_SUB["time"] - df_Json_delayA_PUB["time"] - df_Json_delayB_SUB["time"])/1e9})
array_Proto = diff_Proto_df["Difftime"].to_numpy()
array_Json = diff_Json_df["Difftime"].to_numpy()
avg_Proto = np.average(array_Proto)
avg_Json = np.average(array_Json)
fig = plt.figure()
plt.plot(array_Proto, color="blue", label=f"Proto: {avg_Proto}")
plt.plot(array_Json, color="red", label=f"Json: {avg_Json}")
plt.legend()
plt.xlabel("Number of messages")
plt.ylabel("Delay (s)")
plt.savefig(f"{args.broker}/qos{args.qos}/qos{args.qos}.png", dpi=100)
Loading…
Cancel
Save