From 607e1a425d89b66736720b1f5ae660e500e26eff Mon Sep 17 00:00:00 2001 From: onyinyang Date: Mon, 15 May 2023 19:55:52 -0400 Subject: [PATCH] Remove performance statistics tests for pipeline --- crates/lox-library/Dockerfile | 13 - .../lox-library/Parsing-results/blockages.py | 60 - .../Parsing-results/check_blockages.py | 110 -- .../Parsing-results/make_steady.py | 79 -- .../Parsing-results/make_tables.py | 68 -- .../lox-library/Parsing-results/parse_data.sh | 14 - .../Parsing-results/performance.py | 63 - .../lox-library/Parsing-results/pets_plots.py | 62 - .../lox-library/Parsing-results/raw_to_csv.py | 176 --- .../Parsing-results/requirements.txt | 15 - .../Parsing-results/trust_promo.py | 86 -- .../Parsing-results/trust_promo_plot.py | 74 -- crates/lox-library/README.md | 60 +- crates/lox-library/build-lox.sh | 2 - crates/lox-library/run-lox.sh | 2 - crates/lox-library/run_tests_fast.sh | 29 - crates/lox-library/src/tests.rs | 1050 +---------------- 17 files changed, 2 insertions(+), 1961 deletions(-) delete mode 100644 crates/lox-library/Dockerfile delete mode 100644 crates/lox-library/Parsing-results/blockages.py delete mode 100644 crates/lox-library/Parsing-results/check_blockages.py delete mode 100644 crates/lox-library/Parsing-results/make_steady.py delete mode 100644 crates/lox-library/Parsing-results/make_tables.py delete mode 100755 crates/lox-library/Parsing-results/parse_data.sh delete mode 100644 crates/lox-library/Parsing-results/performance.py delete mode 100644 crates/lox-library/Parsing-results/pets_plots.py delete mode 100644 crates/lox-library/Parsing-results/raw_to_csv.py delete mode 100644 crates/lox-library/Parsing-results/requirements.txt delete mode 100644 crates/lox-library/Parsing-results/trust_promo.py delete mode 100644 crates/lox-library/Parsing-results/trust_promo_plot.py delete mode 100755 crates/lox-library/build-lox.sh delete mode 100755 crates/lox-library/run-lox.sh delete mode 100755 crates/lox-library/run_tests_fast.sh diff --git a/crates/lox-library/Dockerfile b/crates/lox-library/Dockerfile deleted file mode 100644 index 954c37f..0000000 --- a/crates/lox-library/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM rust:1.56.0 -WORKDIR /home/lox -ADD src/ ./src/ -ADD Cargo.toml Cargo.toml -ADD tests/ ./tests/ -ADD run_tests_fast.sh . -ADD Parsing-results ./Parsing-results -ADD README.md README.md -RUN apt update -y -RUN apt install -y python3 python3-pip -RUN pip3 install -r Parsing-results/requirements.txt -RUN cargo build --release -ENV SHELL=/bin/bash diff --git a/crates/lox-library/Parsing-results/blockages.py b/crates/lox-library/Parsing-results/blockages.py deleted file mode 100644 index 6da60c4..0000000 --- a/crates/lox-library/Parsing-results/blockages.py +++ /dev/null @@ -1,60 +0,0 @@ -import pandas as pd -import matplotlib.pyplot as plt -from matplotlib.lines import Line2D - -fig, (axs, axs1) = plt.subplots(2, 4, figsize=(24, 12)) -fig.suptitle("Checking for Blockage and Migration to new Bridges for" + - " Percentage of Bridges Blocked") -columns = ["Percent", "RequestT", "Rtstdev", "ResponseS", "ResponseT", - "ReTstdev", "ResponseHT", "RHTstdev"] -df = pd.read_csv("check_blockage.csv", usecols=columns) -df1 = pd.read_csv("migration.csv", usecols=columns) -fig.supxlabel('Blocked Bridges (%)') -axs[0].set_ylabel('Request Time (ms)') -axs[0].set_ylim([0,70]) -l1 = axs[0].plot(df.Percent, df.RequestT, color='#CC4F1B', - label='Request Time for Percentage of Bridges Blocked') -axs[0].fill_between(df.Percent, df.RequestT-df.Rtstdev, df.RequestT+df.Rtstdev, - alpha=0.5, edgecolor='#CC4F1B', facecolor='#FF9848') -axs1[0].set_ylabel('Request Time (ms)') -axs1[0].set_ylim([0,70]) -axs1[0].plot(df1.Percent, df1.RequestT, color='#1B2ACC', - label='Request Time for Percentage of Bridges Blocked') -axs1[0].fill_between(df1.Percent, df1.RequestT-df1.Rtstdev, - df1.RequestT+df1.Rtstdev, alpha=0.2, edgecolor='#1B2ACC', - facecolor='#089FFF') -axs[1].set_ylabel('Response Time (ms)') -axs[1].plot(df.Percent, df.ResponseT, color='#CC4F1B', - label='Response Time for Percentage of Bridges Blocked') -axs[1].fill_between(df.Percent, df.ResponseT-df.ReTstdev, - df.ResponseT+df.ReTstdev, alpha=0.5, edgecolor='#CC4F1B', - facecolor='#FF9848') -axs1[1].set_ylabel('Response Time (ms)') -axs1[1].set_ylim([0,70]) -axs1[1].plot(df1.Percent, df1.ResponseT, color='#1B2ACC', - label='Response Time for Percentage of Bridges Blocked') -axs1[1].fill_between(df1.Percent, df1.ResponseT-df1.ReTstdev, - df1.ResponseT+df1.ReTstdev, alpha=0.2, edgecolor='#1B2ACC', - facecolor='#089FFF') -axs[2].set_ylabel('Response Size (ms)') -axs[2].plot(df.Percent, df.ResponseS, color='#CC4F1B', - label='Response Size for Percentage of Bridges Blocked') -axs1[2].set_ylabel('Response Size (ms)') -axs1[2].plot(df1.Percent, df1.ResponseS, color='#1B2ACC', - label='Response Size for Percentage of Bridges Blocked') -axs[3].set_ylabel('Response Handling Time (ms)') -axs[3].plot(df.Percent, df.ResponseHT, color='#CC4F1B', - label='Response Handling Time for Percentage of Bridges Blocked') -axs[3].fill_between(df.Percent, df.ResponseHT-df.RHTstdev, - df.ResponseHT+df.RHTstdev, alpha=0.5, edgecolor='#CC4F1B', - facecolor='#FF9848') -axs1[3].set_ylabel('Response Handling Time (ms)') -axs1[3].set_ylim([0,70]) -axs1[3].plot(df1.Percent, df1.ResponseHT, color='#1B2ACC', - label='Response Handling Time for Percentage of Bridges Blocked') -axs1[3].fill_between(df1.Percent, df1.ResponseHT-df1.RHTstdev, - df1.ResponseHT+df1.RHTstdev, alpha=0.2, edgecolor='#1B2ACC', - facecolor='#089FFF') -legend_elements = [Line2D([0], [0], color='#CC4F1B', label="Check Blockage Protocol"), Line2D([0], [0], color='#1B2ACC', label="Blockage Migration Protocol")] -fig.legend(handles=legend_elements, loc='lower right') -fig.savefig("Performance.pdf") diff --git a/crates/lox-library/Parsing-results/check_blockages.py b/crates/lox-library/Parsing-results/check_blockages.py deleted file mode 100644 index 4e820c6..0000000 --- a/crates/lox-library/Parsing-results/check_blockages.py +++ /dev/null @@ -1,110 +0,0 @@ -import sys -import pandas as pd -import matplotlib -import matplotlib.pyplot as plt -from matplotlib.lines import Line2D - - -def main(): - - fig, axs = plt.subplots(1, 3, figsize=(24, 7)) - columns = ["Percent","Bridges", "RequestT", "Rtstdev", "ResponseS", "ResponseT", - "ReTstdev", "ResponseHT", "RHTstdev"] - df = pd.read_csv("standard_check"+".csv", usecols=columns) - df.sort_values(["Percent"], axis=0,ascending=[False], inplace=True) - bridges = df.Bridges*2*3 - fig.supxlabel('Blocked Bridges (%)', size=30) - axs[0].set_ylabel('Response Time (ms)', size=25) - axs[0].tick_params(axis='x', labelsize=15) - axs[0].tick_params(axis='y', labelsize=15) -# axs[0].set_xticklabels('Blocked Bridges (%)',fontsize=10) - axs[0].plot(df.Percent, df.ResponseT, color='#CC4F1B', - label='Response Time for Percentage of Bridges Blocked') - axs[0].fill_between(df.Percent, df.ResponseT-df.ReTstdev, - df.ResponseT+df.ReTstdev, alpha=0.5, edgecolor='#CC4F1B', - facecolor='#FF9848') - axs[1].set_ylabel('Response Size (bytes)', size=25) - axs[1].tick_params(axis='x', labelsize=15) - axs[1].tick_params(axis='y', labelsize=15) - axs[1].plot(df.Percent, df.ResponseS, color='#CC4F1B', - label='Response Size for Percentage of Bridges Blocked') - axs[2].set_ylabel('Response Handling Time (ms)', size=25) - axs[2].tick_params(axis='x', labelsize=15) - axs[2].tick_params(axis='y', labelsize=15) - axs[2].plot(df.Percent, df.ResponseHT, color='#CC4F1B', - label='Response Handling Time for Percentage of Bridges Blocked') - axs[2].fill_between(df.Percent, df.ResponseHT-df.RHTstdev, - df.ResponseHT+df.RHTstdev, alpha=0.5, edgecolor='#CC4F1B', - facecolor='#FF9848') - fig. tight_layout(pad=1) - fig.savefig("StandardCheck.pdf") - plt.close('all') - - for n in range(5,105,5): - fig, axs = plt.subplots(1, 3, figsize=(24, 7)) - columns = ["Percent","Bridges", "RequestT", "Rtstdev", "ResponseS", "ResponseT", - "ReTstdev", "ResponseHT", "RHTstdev"] - df = pd.read_csv("checkblockage"+str(n)+".csv", usecols=columns) - bridges = df.Bridges*2*3 - fig.supxlabel('Total Size of Bridge Pool ('+str(n)+'% Bridges Blocked)',size=30) - axs[0].set_ylabel('Response Time (ms)', size=25) - axs[0].tick_params(axis='x', labelsize=15) - axs[0].tick_params(axis='y', labelsize=15) - axs[0].plot(bridges, df.ResponseT, color='#740202', - label='Response Time for Percentage of Bridges Blocked') - axs[0].fill_between(bridges, df.ResponseT-df.ReTstdev, - df.ResponseT+df.ReTstdev, alpha=0.5, edgecolor='#740202', - facecolor='#E75252') - axs[1].set_ylabel('Response Size (bytes)', size=25) - axs[1].tick_params(axis='x', labelsize=15) - axs[1].tick_params(axis='y', labelsize=15) - axs[1].plot(bridges, df.ResponseS, color='#740202', - label='Response Size for Percentage of Bridges Blocked') - axs[2].set_ylabel('Response Handling Time (ms)', size=25) - axs[2].tick_params(axis='x', labelsize=15) - axs[2].tick_params(axis='y', labelsize=15) - axs[2].plot(bridges, df.ResponseHT, color='#740202', - label='Response Handling Time for Percentage of Bridges Blocked') - axs[2].fill_between(bridges, df.ResponseHT-df.RHTstdev, - df.ResponseHT+df.RHTstdev, alpha=0.5, edgecolor='#740202', - facecolor='#E75252') - fig. tight_layout(pad=1) - fig.savefig("PerformanceVaried"+str(n)+".pdf") - print("\nDone PerformanceVaried"+str(n)+" Plot.\nOutput to: PerformanceVaried"+str(n)+".pdf") - plt.close('all') - - -def set_plot_options(): - options = { - 'font.size': 12, - 'figure.figsize': (4,2), - 'figure.dpi': 100.0, - 'figure.subplot.left': 0.20, - 'figure.subplot.right': 0.97, - 'figure.subplot.bottom': 0.20, - 'figure.subplot.top': 0.90, - 'grid.color': '0.1', - 'grid.linestyle': ':', - #'grid.linewidth': 0.5, - 'axes.grid' : True, - #'axes.grid.axis' : 'y', - #'axes.axisbelow': True, - 'axes.titlesize' : 25, - 'axes.labelsize' : 25, - 'axes.formatter.limits': (-4,4), - 'xtick.labelsize' : 30,#get_tick_font_size_10(), - 'ytick.labelsize' : 30,#get_tick_font_size_10(), - 'lines.linewidth' : 2.0, - 'lines.markeredgewidth' : 0.5, - 'lines.markersize' : 15, - } - - for option_key in options: - matplotlib.rcParams[option_key] = options[option_key] - if 'figure.max_num_figures' in matplotlib.rcParams: - matplotlib.rcParams['figure.max_num_figures'] = 100 - if 'figure.max_open_warning' in matplotlib.rcParams: - matplotlib.rcParams['figure.max_open_warning'] = 100 - -if __name__ == "__main__": - sys.exit(main()) diff --git a/crates/lox-library/Parsing-results/make_steady.py b/crates/lox-library/Parsing-results/make_steady.py deleted file mode 100644 index 674dfee..0000000 --- a/crates/lox-library/Parsing-results/make_steady.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python - -import sys -import json -import lzma -import numpy as np - -import matplotlib -import matplotlib.pyplot as pyplot -import matplotlib.colors as mcolors - - -def main(): - set_plot_options() - buckets = [600, 1200, 1800, 2400, 3000] - n = 1000000 - ft = [] - - pyplot.figure() - for b in buckets: - delta = np.arange(1/10,1,.01) - x = [] - for d in delta: - p = n*(1.61 + (14.71/d+23.725/d**2)/b) / 86400000 - x.append(p) - ft.append(x) - - - pyplot.plot(delta, ft[0], label='600 Buckets') - pyplot.plot(delta, ft[1], linestyle='dotted', label='1200 Buckets') - pyplot.plot(delta, ft[2], linestyle='dashed', label='1800 Buckets') - pyplot.plot(delta, ft[3], linestyle='dashdot', label='2400 Buckets') - pyplot.plot(delta, ft[4], label='3000 Buckets') - pyplot.ylim(bottom=0) - - pyplot.xlabel(r'$\Delta$') - pyplot.ylabel("Cores / Million Users") -# pyplot.title("Average Number of Bridge Users for 1 Month Old Bridges November 2021") - - - pyplot.legend(loc="upper right") - pyplot.tight_layout(pad=1) - pyplot.savefig("core-users.pdf") - -def set_plot_options(): - options = { - #'backend': 'PDF', - 'font.size': 18, - 'figure.figsize': (7,4), - 'figure.dpi': 100.0, - 'axes.grid' : True, - 'axes.xmargin' : 0, - 'axes.grid.axis' : 'y', - 'axes.axisbelow': True, - 'axes.titlesize' : 'medium', - 'axes.labelsize' : 'large', - 'axes.formatter.limits': (-6,6), - 'xtick.labelsize' : 18,#get_tick_font_size_10(), - 'ytick.labelsize' : 18, - 'lines.linewidth' : 2.0, - 'lines.markersize' : 10, - # turn on the following to embedd fonts; requires latex - 'ps.useafm' : True, - 'pdf.use14corefonts' : True, - 'text.usetex' : False, - } - - for option_key in options: - matplotlib.rcParams[option_key] = options[option_key] - - if 'figure.max_num_figures' in matplotlib.rcParams: - matplotlib.rcParams['figure.max_num_figures'] = 100 - if 'figure.max_open_warning' in matplotlib.rcParams: - matplotlib.rcParams['figure.max_open_warning'] = 100 - if 'legend.ncol' in matplotlib.rcParams: - matplotlib.rcParams['legend.ncol'] = 100 - -if __name__ == "__main__": - sys.exit(main()) diff --git a/crates/lox-library/Parsing-results/make_tables.py b/crates/lox-library/Parsing-results/make_tables.py deleted file mode 100644 index 61a0eea..0000000 --- a/crates/lox-library/Parsing-results/make_tables.py +++ /dev/null @@ -1,68 +0,0 @@ -import csv -import sys -import pandas as pd -import numpy as np - - -def main(): - perf = open("performance_stats"+".csv", "w", newline='') - protocols=["Open Invitation", "Trust Promotion(0->1)", - "Trust Migration (0->1)", "Level Up (1->4)", "Issue Invitation", - "Redeem Invitation", "Check Blockage 5%", "Check Blockage 50%", "Check Blockage 100%", "Blockage Migration"] - files = ["trust_levels.csv", "trust_promo.csv", "trust_mig.csv", "level2.csv", - "invitations.csv", "redeem_invites.csv","check_blockage5.csv", - "check_blockage50.csv","check_blockage100.csv","blockage_migration50.csv"] - csv_cols = ["RequestS", "RequestT","Rtstdev","ResponseS","ResponseT", - "ReTstdev", "ResponseHT", "RHTstdev"] - perf_columns = ["Protocol","Request Size", "Request Time", "sigma", - "Response Size","Response Time", "sigma", - "Response Handling Time", "sigma"] - worst_resp = 0 - perfwriter = csv.writer(perf, delimiter=',') - perfwriter.writerow(perf_columns) - - for i, protocol in enumerate(protocols): - columns = ["Percent","Bridges", "RequestS", "Rsstdev", "RequestT", - "Rtstdev", "ResponseS","Restdev","ResponseT", - "ReTstdev", "ResponseHT", "RHTstdev"] - df = pd.read_csv(files[i], usecols=columns) - perf_in = [] - - perf_in.append(protocol) - for item in csv_cols: - row = df[item].loc[df['Bridges']==900].values - if "stdev" in item: - rounded = np.round(row[0], decimals=1) - else: - rounded = np.round(row[0], decimals=3) - perf_in.append(rounded) - rounded = np.round(row[0], decimals=1) - if item == "RequestT": - req = np.round(rounded, decimals=1) - elif item == "ResponseT": - resp_sec = np.round(1000/rounded, decimals=1) - resp_core = resp_sec/(1/(60*60*24)) - if rounded > worst_resp: - worst_resp = rounded - - - perfwriter.writerow(perf_in) - - for i, protocol in enumerate(protocols): - columns = ["Percent","Bridges", "RequestS", "Rsstdev", "RequestT", - "Rtstdev", "ResponseS","Restdev","ResponseT", - "ReTstdev", "ResponseHT", "RHTstdev"] - df = pd.read_csv(files[i], usecols=columns) - row = df['ResponseT'].loc[df['Bridges']==900].values - rounded = np.round(row[0], decimals=3) - resp_sec = np.round(1000/rounded, decimals=3) - resp_core = int(resp_sec/(1/(60*60*24))) - if worst_resp > rounded: - secs = int(worst_resp/1000) - - perf.close() - print("\nDone Tables.\nTable data output to: performance_stats.csv,\n") - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/crates/lox-library/Parsing-results/parse_data.sh b/crates/lox-library/Parsing-results/parse_data.sh deleted file mode 100755 index f8d30fb..0000000 --- a/crates/lox-library/Parsing-results/parse_data.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Parse results from Lox stat tests -echo 'Parse raw output to csv' - -python3 raw_to_csv.py - -echo 'Make plots for data' - -#python3 check_blockages.py -python3 pets_plots.py -#python3 trust_promo_plot.py -python3 make_tables.py -python3 make_steady.py diff --git a/crates/lox-library/Parsing-results/performance.py b/crates/lox-library/Parsing-results/performance.py deleted file mode 100644 index 0a3b58f..0000000 --- a/crates/lox-library/Parsing-results/performance.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python - -import sys -import pandas as pd -import matplotlib -import matplotlib.pyplot as plt -from matplotlib.lines import Line2D - - -def main(): - set_plot_options() - fig, axs = plt.subplots(1) - columns = ["Percent","Bridges", "RequestT", "Rtstdev", "ResponseS", "ResponseT", - "ReTstdev", "ResponseHT", "RHTstdev"] - df = pd.read_csv("standard_check"+".csv", usecols=columns) - df.sort_values(["Percent"], axis=0,ascending=[False], inplace=True) - bridges = df.Bridges*2*3 - axs.set_xlabel('Blocked Bridges (%)') - axs.set_ylabel('Response Time (ms)') - axs.plot(df.Percent, df.ResponseT, color='#CC4F1B', - label='Response Time for Percentage of Bridges Blocked') - axs.set_ylim(bottom=0) - axs.fill_between(df.Percent, df.ResponseT-df.ReTstdev, - df.ResponseT+df.ReTstdev, alpha=0.5, edgecolor='#CC4F1B', - facecolor='#FF9848') - fig. tight_layout(pad=1) - fig.savefig("StandardCheck.pdf") - -def set_plot_options(): - options = { - #'backend': 'PDF', - 'font.size': 18, - 'figure.figsize': (7,3.5), - 'figure.dpi': 100.0, - 'axes.grid' : True, - 'axes.xmargin' : 0, - 'axes.grid.axis' : 'y', - 'axes.axisbelow': True, - 'axes.titlesize' : 'medium', - 'axes.labelsize' : 'large', - 'axes.formatter.limits': (-6,6), - 'xtick.labelsize' : 18,#get_tick_font_size_10(), - 'ytick.labelsize' : 18, - 'lines.linewidth' : 2.0, - 'lines.markersize' : 10, - # turn on the following to embedd fonts; requires latex - 'ps.useafm' : True, - 'pdf.use14corefonts' : True, - 'text.usetex' : False, - } - - for option_key in options: - matplotlib.rcParams[option_key] = options[option_key] - - if 'figure.max_num_figures' in matplotlib.rcParams: - matplotlib.rcParams['figure.max_num_figures'] = 100 - if 'figure.max_open_warning' in matplotlib.rcParams: - matplotlib.rcParams['figure.max_open_warning'] = 100 - if 'legend.ncol' in matplotlib.rcParams: - matplotlib.rcParams['legend.ncol'] = 100 - -if __name__ == "__main__": - sys.exit(main()) diff --git a/crates/lox-library/Parsing-results/pets_plots.py b/crates/lox-library/Parsing-results/pets_plots.py deleted file mode 100644 index df8557f..0000000 --- a/crates/lox-library/Parsing-results/pets_plots.py +++ /dev/null @@ -1,62 +0,0 @@ -import sys -import pandas as pd -import matplotlib -import matplotlib.pyplot as plt -from matplotlib.lines import Line2D - - -def main(): - - plt.figure(figsize=(9, 5)) - columns = ["Percent","Bridges", "RequestT", "Rtstdev", "ResponseS", "ResponseT", - "ReTstdev", "ResponseHT", "RHTstdev"] - df = pd.read_csv("standard_check"+".csv", usecols=columns) - df.sort_values(["Percent"], axis=0,ascending=[False], inplace=True) - bridges = df.Bridges*2*3 - plt.xlabel('Blocked Bridges (%)', size=20) - plt.ylabel('Response Time (ms)', size=20) - plt.tick_params(axis='x', labelsize=15) - plt.tick_params(axis='y', labelsize=15) - plt.plot(df.Percent, df.ResponseT, color='#CC4F1B', - label='Response Time for Percentage of Bridges Blocked') - plt.fill_between(df.Percent, df.ResponseT-df.ReTstdev, - df.ResponseT+df.ReTstdev, alpha=0.5, edgecolor='#CC4F1B', - facecolor='#FF9848') - plt.tight_layout(pad=1) - plt.savefig("Blockage-response-time.pdf") - plt.close('all') - -def set_plot_options(): - options = { - 'font.size': 12, - 'figure.figsize': (10,2), - 'figure.dpi': 100.0, - 'figure.subplot.left': 0.20, - 'figure.subplot.right': 0.97, - 'figure.subplot.bottom': 0.20, - 'figure.subplot.top': 0.90, - 'grid.color': '0.1', - 'grid.linestyle': ':', - #'grid.linewidth': 0.5, - 'axes.grid' : True, - #'axes.grid.axis' : 'y', - #'axes.axisbelow': True, - 'axes.titlesize' : 25, - 'axes.labelsize' : 25, - 'axes.formatter.limits': (-4,4), - 'xtick.labelsize' : 30,#get_tick_font_size_10(), - 'ytick.labelsize' : 30,#get_tick_font_size_10(), - 'lines.linewidth' : 2.0, - 'lines.markeredgewidth' : 0.5, - 'lines.markersize' : 15, - } - - for option_key in options: - matplotlib.rcParams[option_key] = options[option_key] - if 'figure.max_num_figures' in matplotlib.rcParams: - matplotlib.rcParams['figure.max_num_figures'] = 100 - if 'figure.max_open_warning' in matplotlib.rcParams: - matplotlib.rcParams['figure.max_open_warning'] = 100 - -if __name__ == "__main__": - sys.exit(main()) diff --git a/crates/lox-library/Parsing-results/raw_to_csv.py b/crates/lox-library/Parsing-results/raw_to_csv.py deleted file mode 100644 index 090cd8e..0000000 --- a/crates/lox-library/Parsing-results/raw_to_csv.py +++ /dev/null @@ -1,176 +0,0 @@ -from pathlib import Path - -standard_check_file = open("standard_check"+".csv", "w") -standard_check_file.write("Percent,Bridges,RequestS,Rsstdev,RequestT,Rtstdev,ResponseS,Restdev,ResponseT,ReTstdev,ResponseHT,RHTstdev\n") - -for p in Path('.').glob('*.log'): - print(f"Parsing: {p.name.strip('.log')}\n") - with p.open() as log_file: - test_file = open(p.name.strip('.log')+".csv", "w") - test_file.write("Percent,Bridges,RequestS,Rsstdev,RequestT,Rtstdev,ResponseS,Restdev,ResponseT,ReTstdev,ResponseHT,RHTstdev\n") - bridges = 0 - c=False - red = 0 - check = 0 - level = 0 - protocol = 0 - num = 0 - req_size = 0 - req_size_std = 0 - req_time = 0 - req_time_std = 0 - resp_size = 0 - resp_size_std = 0 - resp_time = 0 - resp_time_std = 0 - resp_handle_time = 0 - resp_handle_std = 0 - endline = 0 - - # Loop over the remaining lines in the file - for line in log_file: - if "***START" in line: - bridges = line.split()[1].split("*")[0] - if "CHECK-BLOCKAGE" in line: - protocol = 1 - num = line.split("-")[6].strip('-') - if int(bridges) == 900: - check =1 - if not c: - check_b = open("check_blockage"+str(num)+".csv", "w") - check_b.write("Percent,Bridges,RequestS,Rsstdev,RequestT,Rtstdev,ResponseS,Restdev,ResponseT,ReTstdev,ResponseHT,RHTstdev\n") - c=True - elif "BLOCKAGE-MIGRATION" in line: - protocol = 2 - num = line.split("-")[6].strip('-') - elif "REDEEM" in line: - protocol = 3 - if not red: - redeem = open("redeem_invites.csv", "w") - redeem.write("Percent,Bridges,RequestS,Rsstdev,RequestT,Rtstdev,ResponseS,Restdev,ResponseT,ReTstdev,ResponseHT,RHTstdev\n") - red = 1 - elif "ISSUE" in line: - protocol = 4 - elif "OPEN" in line: - protocol = 5 - elif "TRUST-PROMOTION" in line: - protocol = 6 - if not level: - trust_promo = open("trust_promo.csv", "w") - trust_promo.write("Percent,Bridges,RequestS,Rsstdev,RequestT,Rtstdev,ResponseS,Restdev,ResponseT,ReTstdev,ResponseHT,RHTstdev\n") - elif "TRUST-MIGRATION" in line: - protocol = 7 - if not level: - mig_file = open("trust_mig.csv", "w") - mig_file.write("Percent,Bridges,RequestS,Rsstdev,RequestT,Rtstdev,ResponseS,Restdev,ResponseT,ReTstdev,ResponseHT,RHTstdev\n") - elif "LEVEL-UP-2" in line: - protocol = 8 - if not level: - level_file = open("level2.csv", "w") - level_file.write("Percent,Bridges,RequestS,Rsstdev,RequestT,Rtstdev,ResponseS,Restdev,ResponseT,ReTstdev,ResponseHT,RHTstdev\n") - elif "LEVEL-UP-3" in line: - protocol = 9 - if not level: - level_file_t = open("level3.csv", "w") - level_file_t.write("Percent,Bridges,RequestS,Rsstdev,RequestT,Rtstdev,ResponseS,Restdev,ResponseT,ReTstdev,ResponseHT,RHTstdev\n") - elif "LEVEL-UP-4" in line: - protocol = 10 - if not level: - level_file_f = open("level4.csv", "w") - level_file_f.write("Percent,Bridges,RequestS,Rsstdev,RequestT,Rtstdev,ResponseS,Restdev,ResponseT,ReTstdev,ResponseHT,RHTstdev\n") - level = 1 - elif protocol: - value = line.split(" = ") - if value[0].startswith("Average"): - if "request" in value[0]: - if "size" in value[0]: - raw_size = value[1].split(" ") - req_size = raw_size[0] - else: - if "µ" in value[1]: - micro_sec = value[1].split("µ") - raw_size = float(micro_sec[0])*0.001 - elif "m" not in value[1]: - sec = value[1][:-3] - raw_size = float(sec)*1000 - else: - raw_size = value[1][:-3] - req_time = raw_size - else: - if "size" in value[0]: - raw_size = value[1].split(" ") - resp_size = raw_size[0] - else: - if "µ" in value[1]: - micro_sec = value[1].split("µ") - raw_size = float(micro_sec[0])*0.001 - elif "m" not in value[1]: - sec = value[1][:-3] - raw_size = float(sec)*1000 - else: - raw_size = value[1][:-3] - if "handling" in value[0]: - resp_handle_time = raw_size - else: - resp_time = raw_size - elif value[0].startswith("Request"): - if "size" in value[0]: - raw_size = value[1].split(" ") - req_size_std = raw_size[0] - else: - if "µ" in value[1]: - micro_sec = value[1].split("µ") - to_sec = float(micro_sec[0])*0.001 - else: - to_sec = value[1][:-3] - req_time_std = to_sec - elif value[0].startswith("Response"): - if "size" in value[0]: - raw_size = value[1].split(" ") - resp_size_std = raw_size[0] - else: - if "µ" in value[1]: - micro_sec = value[1].split("µ") - to_sec = float(micro_sec[0])*0.001 - else: - to_sec = value[1][:-3] - if "handling" in value[0]: - resp_handle_time_std = to_sec - endline = 1 - else: - resp_time_std = to_sec - - if endline == 1: - if check == 1: - standard_check_file.write(str(num) + "," + str(bridges)+"," + str(req_size) + "," + str(req_size_std) + "," + str(req_time) + "," + str(req_time_std) + "," + str(resp_size) + "," + str(resp_size_std) + "," + str(resp_time) + "," + str(resp_time_std) + "," + str(resp_handle_time) + "," + str(resp_handle_time_std) + "\n") - check = 0 - if protocol == 1: - check_b.write(str(num) + "," + str(bridges)+"," + str(req_size) + "," + str(req_size_std) + "," + str(req_time) + "," + str(req_time_std) + "," + str(resp_size) + "," + str(resp_size_std) + "," + str(resp_time) + "," + str(resp_time_std) + "," + str(resp_handle_time) + "," + str(resp_handle_time_std) + "\n") - elif protocol == 3: - redeem.write(str(num) + "," + str(bridges)+"," + str(req_size) + "," + str(req_size_std) + "," + str(req_time) + "," + str(req_time_std) + "," + str(resp_size) + "," + str(resp_size_std) + "," + str(resp_time) + "," + str(resp_time_std) + "," + str(resp_handle_time) + "," + str(resp_handle_time_std) + "\n") - elif protocol<6: - test_file.write(str(num) + "," + str(bridges)+"," + str(req_size) + "," + str(req_size_std) + "," + str(req_time) + "," + str(req_time_std) + "," + str(resp_size) + "," + str(resp_size_std) + "," + str(resp_time) + "," + str(resp_time_std) + "," + str(resp_handle_time) + "," + str(resp_handle_time_std) + "\n") - else: - if protocol == 6: - trust_promo.write(str(num) + "," + str(bridges)+"," + str(req_size) + "," + str(req_size_std) + "," + str(req_time) + "," + str(req_time_std) + "," + str(resp_size) + "," + str(resp_size_std) + "," + str(resp_time) + "," + str(resp_time_std) + "," + str(resp_handle_time) + "," + str(resp_handle_time_std) + "\n") - if protocol == 7: - mig_file.write(str(num) + "," + str(bridges)+"," + str(req_size) + "," + str(req_size_std) + "," + str(req_time) + "," + str(req_time_std) + "," + str(resp_size) + "," + str(resp_size_std) + "," + str(resp_time) + "," + str(resp_time_std) + "," + str(resp_handle_time) + "," + str(resp_handle_time_std) + "\n") - if protocol == 8: - level_file.write(str(num) + "," + str(bridges)+"," + str(req_size) + "," + str(req_size_std) + "," + str(req_time) + "," + str(req_time_std) + "," + str(resp_size) + "," + str(resp_size_std) + "," + str(resp_time) + "," + str(resp_time_std) + "," + str(resp_handle_time) + "," + str(resp_handle_time_std) + "\n") - elif protocol == 9: - level_file_t.write(str(num) + "," + str(bridges)+"," + str(req_size) + "," + str(req_size_std) + "," + str(req_time) + "," + str(req_time_std) + "," + str(resp_size) + "," + str(resp_size_std) + "," + str(resp_time) + "," + str(resp_time_std) + "," + str(resp_handle_time) + "," + str(resp_handle_time_std) + "\n") - elif protocol == 10: - level_file_f.write(str(num) + "," + str(bridges)+"," + str(req_size) + "," + str(req_size_std) + "," + str(req_time) + "," + str(req_time_std) + "," + str(resp_size) + "," + str(resp_size_std) + "," + str(resp_time) + "," + str(resp_time_std) + "," + str(resp_handle_time) + "," + str(resp_handle_time_std) + "\n") - endline = 0 - protocol = 0 - if level: - level_file.close() - level_file_t.close() - level_file_f.close() - trust_promo.close() - mig_file.close() - if red: - redeem.close() - test_file.close() -standard_check_file.close() -print("Done.") diff --git a/crates/lox-library/Parsing-results/requirements.txt b/crates/lox-library/Parsing-results/requirements.txt deleted file mode 100644 index 77e0143..0000000 --- a/crates/lox-library/Parsing-results/requirements.txt +++ /dev/null @@ -1,15 +0,0 @@ -contourpy==1.0.5 -cycler==0.11.0 -fonttools==4.37.4 -kiwisolver==1.4.4 -matplotlib==3.6.1 -mercurial==5.6.1 -numpy==1.23.4 -packaging==21.3 -pandas==1.5.0 -Pillow==9.2.0 -pyparsing==3.0.9 -python-dateutil==2.8.2 -pytz==2022.4 -six==1.16.0 - diff --git a/crates/lox-library/Parsing-results/trust_promo.py b/crates/lox-library/Parsing-results/trust_promo.py deleted file mode 100644 index c8fb0ae..0000000 --- a/crates/lox-library/Parsing-results/trust_promo.py +++ /dev/null @@ -1,86 +0,0 @@ -log_file = open("trust_levels.log", "r").readlines() -trust_promo_file = open("trust_promo"+".csv", "w") -trust_promo_file.write("Bridges,RequestS,Rsstdev,RequestT,Rtstdev,ResponseS,Restdev,ResponseT,ReTstdev,ResponseHT,RHTstdev\n") - - -bridges = 0 -promo = 0 -req_size = 0 -req_size_std = 0 -req_time = 0 -req_time_std = 0 -resp_size = 0 -resp_size_std = 0 -resp_time = 0 -resp_time_std = 0 -resp_handle_time = 0 -resp_handle_std = 0 -endline = 0 - -# Loop over the remaining lines in the file -for line in log_file: - if "***START" in line: - bridges = line.split()[1].split("*")[0] - elif "TRUST-PROMOTION" in line: - promo = 1 - elif promo: - value = line.split(" = ") - if value[0].startswith("Average"): - if "request" in value[0]: - if "size" in value[0]: - raw_size = value[1].split(" ") - req_size = raw_size[0] - else: - raw_size = value[1] - req_time = raw_size[:-3] - else: - if "size" in value[0]: - raw_size = value[1].split(" ") - resp_size = raw_size[0] - else: - raw_size = value[1] - if "handling" in value[0]: - resp_handle_time = raw_size[:-3] - elif (value[1][-3]) != "m": - sec = value[1][:-3] - resp_time = float(sec)*1000 - else: - resp_time = raw_size[:-3] - elif value[0].startswith("Request"): - if "size" in value[0]: - raw_size = value[1].split(" ") - req_size_std = raw_size[0] - else: - if "µ" in value[1]: - micro_sec = value[1].split("µ") - to_sec = float(micro_sec[0])*0.001 - else: - to_sec = value[1][:-3] - req_time_std = to_sec - - elif value[0].startswith("Response"): - if "size" in value[0]: - raw_size = value[1].split(" ") - resp_size_std = raw_size[0] - elif "bytes" in value[1]: - continue - else: - if "µ" in value[1]: - micro_sec = value[1].split("µ") - to_sec = float(micro_sec[0])*0.001 - else: - to_sec = value[1][:-3] - if "handling" in value[0]: - resp_handle_time_std = to_sec - endline = 1 - else: - resp_time_std = to_sec - - if endline == 1: - if promo == 1: - trust_promo_file.write(str(bridges)+"," + str(req_size) + "," + str(req_size_std) + "," + str(req_time) + "," + str(req_time_std) + "," + str(resp_size) + "," + str(resp_size_std) + "," + str(resp_time) + "," + str(resp_time_std) + "," + str(resp_handle_time) + "," + str(resp_handle_time_std) + "\n") - promo = 0 - endline = 0 - -trust_promo_file.close() -print("Done.") diff --git a/crates/lox-library/Parsing-results/trust_promo_plot.py b/crates/lox-library/Parsing-results/trust_promo_plot.py deleted file mode 100644 index 7c1eaea..0000000 --- a/crates/lox-library/Parsing-results/trust_promo_plot.py +++ /dev/null @@ -1,74 +0,0 @@ -import sys -import pandas as pd -import matplotlib -import matplotlib.pyplot as plt -from matplotlib.lines import Line2D - - -def main(): - - fig, axs = plt.subplots(1, 3, figsize=(24, 7)) - columns = ["Bridges", "RequestT", "Rtstdev", "ResponseS", "ResponseT", - "ReTstdev", "ResponseHT", "RHTstdev"] - df = pd.read_csv("trust_promo"+".csv", usecols=columns) - bridges = df.Bridges*2*3 - fig.supxlabel('Total Size of Bridge Pool',size=30) - axs[0].set_ylabel('Response Time (ms)', size=25) - axs[0].tick_params(axis='x', labelsize=15) - axs[0].tick_params(axis='y', labelsize=15) - axs[0].plot(bridges, df.ResponseT, color='#29135F', - label='Response Time for Trust Promotion') - axs[0].fill_between(bridges, df.ResponseT-df.ReTstdev, - df.ResponseT+df.ReTstdev, alpha=0.5, edgecolor='#29135F', - facecolor='#8967E2') - axs[1].set_ylabel('Response Size (bytes)', size=25) - axs[1].tick_params(axis='x', labelsize=15) - axs[1].tick_params(axis='y', labelsize=15) - axs[1].plot(bridges, df.ResponseS, color='#29135F', - label='Response Size for Trust Promotion') - axs[2].set_ylabel('Response Handling Time (ms)', size=25) - axs[2].tick_params(axis='x', labelsize=15) - axs[2].tick_params(axis='y', labelsize=15) - axs[2].plot(bridges, df.ResponseHT, color='#29135F', - label='Response Handling Time for Trust Promotion') - axs[2].fill_between(bridges, df.ResponseHT-df.RHTstdev, - df.ResponseHT+df.RHTstdev, alpha=0.5, edgecolor='#29135F', - facecolor='#8967E2') - fig. tight_layout(pad=1) - fig.savefig("TrustPromotion.pdf") - print("\nDone Trust Promotion Plot.\nOutput to: TrustPromotion.pdf") - -def set_plot_options(): - options = { - 'font.size': 12, - 'figure.figsize': (4,2), - 'figure.dpi': 100.0, - 'figure.subplot.left': 0.20, - 'figure.subplot.right': 0.97, - 'figure.subplot.bottom': 0.20, - 'figure.subplot.top': 0.90, - 'grid.color': '0.1', - 'grid.linestyle': ':', - #'grid.linewidth': 0.5, - 'axes.grid' : True, - #'axes.grid.axis' : 'y', - #'axes.axisbelow': True, - 'axes.titlesize' : 'large', - 'axes.labelsize' : 'x-large', - 'axes.formatter.limits': (-4,4), - 'xtick.labelsize' : 20,#get_tick_font_size_10(), - 'ytick.labelsize' : 20,#get_tick_font_size_10(), - 'lines.linewidth' : 2.0, - 'lines.markeredgewidth' : 0.5, - 'lines.markersize' : 10, - } - - for option_key in options: - matplotlib.rcParams[option_key] = options[option_key] - if 'figure.max_num_figures' in matplotlib.rcParams: - matplotlib.rcParams['figure.max_num_figures'] = 100 - if 'figure.max_open_warning' in matplotlib.rcParams: - matplotlib.rcParams['figure.max_open_warning'] = 100 - -if __name__ == "__main__": - sys.exit(main()) diff --git a/crates/lox-library/README.md b/crates/lox-library/README.md index 009b37d..e05f6fa 100644 --- a/crates/lox-library/README.md +++ b/crates/lox-library/README.md @@ -3,64 +3,6 @@ Lox is a reputation-based bridge distribution system that provides privacy protection to users and their social graph and is open to all users. Lox is written in rust and requires `cargo` to test. [Install Rust](https://www.rust-lang.org/tools/install). We used Rust version 1.56.0. -### To use the docker environment to build the package: - -``` -./build-lox.sh -./run-lox.sh -``` - -### To run each of the tests used for our experimental results run: - -``` -cargo test --release -- --nocapture TESTNAME > LOGFILE -``` - -Where `TESTNAME > LOGFILE` is one of: - -``` -stats_test_trust_levels > trust_levels.log -stats_test_invitations > invitations.log -stats_test_percent_blockage_migration_05 > blockage_migration05.log -stats_test_percent_blockage_migration_010 > blockage_migration010.log -stats_test_percent_blockage_migration_20 > blockage_migration20.log -stats_test_percent_blockage_migration_25 > blockage_migration25.log -stats_test_percent_blockage_migration_35 > blockage_migration35.log -stats_test_percent_blockage_migration_40 > blockage_migration40.log -stats_test_percent_blockage_migration_45 > blockage_migration45.log -stats_test_percent_blockage_migration_50 > blockage_migration50.log -stats_test_percent_blockage_migration_55 > blockage_migration55.log -stats_test_percent_blockage_migration_60 > blockage_migration60.log -stats_test_percent_blockage_migration_65 > blockage_migration65.log -stats_test_percent_blockage_migration_70 > blockage_migration70.log -stats_test_percent_blockage_migration_75 > blockage_migration75.log -stats_test_percent_blockage_migration_80 > blockage_migration80.log -stats_test_percent_blockage_migration_85 > blockage_migration85.log -stats_test_percent_blockage_migration_90 > blockage_migration90.log -stats_test_percent_blockage_migration_95 > blockage_migration95.log -stats_test_percent_blockage_migration_100 > blockage_migration100.log -``` - -Each test outputs results to the specified log file and takes approximately 20-30 hours to run. However, this can be improved -by passing the `fast` feature. Using this feature, our tests are run for 100 -users instead of 10000 users and will produce results comparable to our -reported results (with larger error margins). To run individual tests with this -flag run: - -``` -cargo test --release --features=fast -- --nocapture TESTNAME > LOGFILE -``` - -We have also included the scripts we used to parse the output from each of the Lox tests in the `Parsing-results` directory. For convenience, copy all of the output log files to the `Parsing-results` directory and run `./parse_data.sh`. This is a python script that uses Python 3.8+ and depends on `numpy`, `matplotlib`, and `pandas` which can be installed with `pip3`. - -To run all tests in fast mode, output the results to the `Parsing-results` directory, and generate the table (`performance_stats.csv`, our Table 4) and graphs (`Blockage-response-time.pdf` and `core-users.pdf`, our Figures 1 and 2) used in our paper, run: - -``` -./run_tests_fast -``` - -This takes 5–6 hours to complete on the 2011-era E7-8870 processor we used for the measurements in the paper. Newer processors will likely take less time. Note that with the `fast` feature, it is possible that some tests may only yield 0 or 1 data points, in which case you will see `0` for the times and/or stddevs in the resulting `performance_stats.csv` table for those tests. - -Note that our implementation is coded such that the reachability certificate expires at 00:00 UTC. A workaround has been included in each test to pause if it is too close to this time so the request won't fail. In reality, if the bucket is still reachable, a user could simply request a new reachability token if their request fails for this reason (a new certificate should be available prior to the outdated certificate expiring). +Note that this implementation is coded such that the reachability certificate expires at 00:00 UTC. In reality, if the bucket is still reachable, a user could simply request a new reachability token if their request fails for this reason (a new certificate should be available prior to the outdated certificate expiring). diff --git a/crates/lox-library/build-lox.sh b/crates/lox-library/build-lox.sh deleted file mode 100755 index 141dda5..0000000 --- a/crates/lox-library/build-lox.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -docker build -t lox . diff --git a/crates/lox-library/run-lox.sh b/crates/lox-library/run-lox.sh deleted file mode 100755 index e95657d..0000000 --- a/crates/lox-library/run-lox.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -docker run --name lox --rm -it lox:latest /bin/bash diff --git a/crates/lox-library/run_tests_fast.sh b/crates/lox-library/run_tests_fast.sh deleted file mode 100755 index 4b43063..0000000 --- a/crates/lox-library/run_tests_fast.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -cargo test --release --features=fast -- --nocapture stats_test_trust_levels > trust_levels.log -cargo test --release --features=fast -- --nocapture stats_test_invitations > invitations.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_05 > blockage_migration05.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_010 > blockage_migration010.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_20 > blockage_migration20.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_25 > blockage_migration25.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_30 > blockage_migration30.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_35 > blockage_migration35.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_40 > blockage_migration40.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_45 > blockage_migration45.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_50 > blockage_migration50.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_55 > blockage_migration55.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_60 > blockage_migration60.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_65 > blockage_migration65.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_70 > blockage_migration70.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_75 > blockage_migration75.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_80 > blockage_migration80.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_85 > blockage_migration85.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_90 > blockage_migration90.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_95 > blockage_migration95.log -cargo test --release --features=fast -- --nocapture stats_test_percent_blockage_migration_100 > blockage_migration100.log -echo "Completed all tests, now parsing results" -mv *.log Parsing-results -cd Parsing-results -./parse_data.sh -echo "Parse results are in the Parsing-results folder." - diff --git a/crates/lox-library/src/tests.rs b/crates/lox-library/src/tests.rs index 5627d9a..fe696c6 100644 --- a/crates/lox-library/src/tests.rs +++ b/crates/lox-library/src/tests.rs @@ -4,18 +4,9 @@ BridgeLine::random() or private fields */ use super::bridge_table::{BridgeLine, BRIDGE_BYTES}; use super::proto::*; use super::*; -use chrono::{DateTime, NaiveTime, Timelike, Utc}; use rand::Rng; -use statistical::{mean, standard_deviation}; -use std::collections::HashSet; -use std::thread; use std::time::{Duration, Instant}; -#[cfg(feature = "fast")] -const USERS: usize = 100; -#[cfg(not(feature = "fast"))] -const USERS: usize = 10000; - struct PerfStat { // Report performance metrics for each test req_len: usize, @@ -995,1049 +986,10 @@ fn test_blockage_migration() { assert!(th.ba.verify_lox(&cred4)); } -#[test] -fn stats_test_trust_levels() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - - let mut promo_req_size: Vec = Vec::new(); - let mut promo_resp_size: Vec = Vec::new(); - let mut promo_req_time: Vec = Vec::new(); - let mut promo_resp_time: Vec = Vec::new(); - let mut promo_resp_handle_time: Vec = Vec::new(); - let mut mig_req_size: Vec = Vec::new(); - let mut mig_resp_size: Vec = Vec::new(); - let mut mig_req_time: Vec = Vec::new(); - let mut mig_resp_time: Vec = Vec::new(); - let mut mig_resp_handle_time: Vec = Vec::new(); - let mut sec_req_size: Vec = Vec::new(); - let mut sec_resp_size: Vec = Vec::new(); - let mut sec_req_time: Vec = Vec::new(); - let mut sec_resp_time: Vec = Vec::new(); - let mut sec_resp_handle_time: Vec = Vec::new(); - let mut three_req_size: Vec = Vec::new(); - let mut three_resp_size: Vec = Vec::new(); - let mut three_req_time: Vec = Vec::new(); - let mut three_resp_time: Vec = Vec::new(); - let mut three_resp_handle_time: Vec = Vec::new(); - let mut four_req_size: Vec = Vec::new(); - let mut four_resp_size: Vec = Vec::new(); - let mut four_req_time: Vec = Vec::new(); - let mut four_resp_time: Vec = Vec::new(); - let mut four_resp_handle_time: Vec = Vec::new(); - let mut open_req_size: Vec = Vec::new(); - let mut open_resp_size: Vec = Vec::new(); - let mut open_req_time: Vec = Vec::new(); - let mut open_resp_time: Vec = Vec::new(); - let mut open_resp_handle_time: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let (open_perf_stat, cred) = th.open_invite(); - th.advance_days(30); - let (tp_perf_stat, migcred) = th.trust_promotion(&cred.0); - let (mig_perf_stat, cred1) = th.level0_migration(&cred.0, &migcred); - th.advance_days(14); - let (sec_perf_stat, cred2) = th.level_up(&cred1); - th.advance_days(28); - let (three_perf_stat, cred3) = th.level_up(&cred2); - th.advance_days(56); - let (four_perf_stat, _) = th.level_up(&cred3); - open_req_size.push(open_perf_stat.req_len as f64); - open_req_time.push(open_perf_stat.req_t.as_secs_f64()); - open_resp_size.push(open_perf_stat.resp_len as f64); - open_resp_time.push(open_perf_stat.resp_t.as_secs_f64()); - open_resp_handle_time.push(open_perf_stat.resp_handle_t.as_secs_f64()); - promo_req_size.push(tp_perf_stat.req_len as f64); - promo_req_time.push(tp_perf_stat.req_t.as_secs_f64()); - promo_resp_size.push(tp_perf_stat.resp_len as f64); - promo_resp_time.push(tp_perf_stat.resp_t.as_secs_f64()); - promo_resp_handle_time.push(tp_perf_stat.resp_handle_t.as_secs_f64()); - mig_req_size.push(mig_perf_stat.req_len as f64); - mig_req_time.push(mig_perf_stat.req_t.as_secs_f64()); - mig_resp_size.push(mig_perf_stat.resp_len as f64); - mig_resp_time.push(mig_perf_stat.resp_t.as_secs_f64()); - mig_resp_handle_time.push(mig_perf_stat.resp_handle_t.as_secs_f64()); - sec_req_size.push(sec_perf_stat.req_len as f64); - sec_req_time.push(sec_perf_stat.req_t.as_secs_f64()); - sec_resp_size.push(sec_perf_stat.resp_len as f64); - sec_resp_time.push(sec_perf_stat.resp_t.as_secs_f64()); - sec_resp_handle_time.push(sec_perf_stat.resp_handle_t.as_secs_f64()); - three_req_size.push(three_perf_stat.req_len as f64); - three_req_time.push(three_perf_stat.req_t.as_secs_f64()); - three_resp_size.push(three_perf_stat.resp_len as f64); - three_resp_time.push(three_perf_stat.resp_t.as_secs_f64()); - three_resp_handle_time.push(three_perf_stat.resp_handle_t.as_secs_f64()); - four_req_size.push(four_perf_stat.req_len as f64); - four_req_time.push(four_perf_stat.req_t.as_secs_f64()); - four_resp_size.push(four_perf_stat.resp_len as f64); - four_resp_time.push(four_perf_stat.resp_t.as_secs_f64()); - four_resp_handle_time.push(four_perf_stat.resp_handle_t.as_secs_f64()); - } - - println!("\n***START: {}*3*2 BUCKETS LEVELS***\n", x); - println!("\n----OPEN-INVITATION-{}---\n", x); - print_stats_test_results( - open_req_size, - open_req_time, - open_resp_size, - open_resp_time, - open_resp_handle_time, - ); - - println!("\n----TRUST-PROMOTION-1: 30 days-{}---\n", x); - print_stats_test_results( - promo_req_size, - promo_req_time, - promo_resp_size, - promo_resp_time, - promo_resp_handle_time, - ); - - println!("\n----TRUST-MIGRATION-0: 30 days-{}---\n", x); - print_stats_test_results( - mig_req_size, - mig_req_time, - mig_resp_size, - mig_resp_time, - mig_resp_handle_time, - ); - - println!("\n----LEVEL-UP-2: 44 days-{}---\n", x); - print_stats_test_results( - sec_req_size, - sec_req_time, - sec_resp_size, - sec_resp_time, - sec_resp_handle_time, - ); - - println!("\n----LEVEL-UP-3: 72 days---{}---\n", x); - print_stats_test_results( - three_req_size, - three_req_time, - three_resp_size, - three_resp_time, - three_resp_handle_time, - ); - - println!("\n----LEVEL-UP-4: 128 days---{}---\n", x); - print_stats_test_results( - four_req_size, - four_req_time, - four_resp_size, - four_resp_time, - four_resp_handle_time, - ); - } -} - -#[test] -fn stats_test_invitations() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - - let mut req_size: Vec = Vec::new(); - let mut resp_size: Vec = Vec::new(); - let mut req_time: Vec = Vec::new(); - let mut resp_time: Vec = Vec::new(); - let mut resp_handle_time: Vec = Vec::new(); - let mut red_req_size: Vec = Vec::new(); - let mut red_resp_size: Vec = Vec::new(); - let mut red_req_time: Vec = Vec::new(); - let mut red_resp_time: Vec = Vec::new(); - let mut red_resp_handle_time: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - th.advance_days(28); - let (perf_stat, (_, invite)) = th.issue_invite(&cred2); - let (bob_perf_stat, _) = th.redeem_invite(&invite); - req_size.push(perf_stat.req_len as f64); - req_time.push(perf_stat.req_t.as_secs_f64()); - resp_size.push(perf_stat.resp_len as f64); - resp_time.push(perf_stat.resp_t.as_secs_f64()); - resp_handle_time.push(perf_stat.resp_handle_t.as_secs_f64()); - red_req_size.push(bob_perf_stat.req_len as f64); - red_req_time.push(bob_perf_stat.req_t.as_secs_f64()); - red_resp_size.push(bob_perf_stat.resp_len as f64); - red_resp_time.push(bob_perf_stat.resp_t.as_secs_f64()); - red_resp_handle_time.push(bob_perf_stat.resp_handle_t.as_secs_f64()); - } - - println!("\n***START: {}*3*2 BUCKETS INVITATIONS***\n", x); - println!("\n----ISSUE-INVITATION-{}---\n", x); - print_stats_test_results(req_size, req_time, resp_size, resp_time, resp_handle_time); - - println!("\n----REDEEM-INVITATION-{}---\n", x); - print_stats_test_results( - red_req_size, - red_req_time, - red_resp_size, - red_resp_time, - red_resp_handle_time, - ); - } -} - -#[test] -fn stats_test_percent_blockage_migration_05() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 5***\n", x); - block_bridges(&mut th, 5, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_010() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 10***\n", x); - block_bridges(&mut th, 10, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_15() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 15***\n", x); - block_bridges(&mut th, 15, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_20() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 20***\n", x); - block_bridges(&mut th, 20, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_25() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 25***\n", x); - block_bridges(&mut th, 25, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_30() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 30***\n", x); - block_bridges(&mut th, 30, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_35() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 35***\n", x); - block_bridges(&mut th, 35, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_40() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 40***\n", x); - block_bridges(&mut th, 40, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_45() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 45***\n", x); - block_bridges(&mut th, 45, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_50() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 50***\n", x); - block_bridges(&mut th, 50, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_55() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 55***\n", x); - block_bridges(&mut th, 55, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_60() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 60***\n", x); - block_bridges(&mut th, 60, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_65() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 65***\n", x); - block_bridges(&mut th, 65, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_70() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 70***\n", x); - block_bridges(&mut th, 70, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_75() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 75***\n", x); - block_bridges(&mut th, 75, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_80() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 80***\n", x); - block_bridges(&mut th, 80, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_85() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 85***\n", x); - block_bridges(&mut th, 85, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_90() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 90***\n", x); - block_bridges(&mut th, 90, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_95() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - - println!("\n***START: {}*3*2 BUCKETS 95***\n", x); - block_bridges(&mut th, 95, credentials); - } -} - -#[test] -fn stats_test_percent_blockage_migration_100() { - let buckets: Vec = vec![150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500]; - - for x in buckets { - let mut th = TestHarness::new_buckets(x, x); - let mut credentials: Vec = Vec::new(); - for _ in 0..USERS { - let h: NaiveTime = DateTime::time(&Utc::now()); - if h.hour() == 23 && h.minute() == 59 { - println!("Wait for UTC 00:00"); - thread::sleep(Duration::new(60, 0)); - println!("Ready to work again"); - } - let cred = th.open_invite().1 .0; - th.advance_days(30); - let (_, migcred) = th.trust_promotion(&cred); - let (_, cred1) = th.level0_migration(&cred, &migcred); - th.advance_days(14); - let (_, cred2) = th.level_up(&cred1); - let (_, (cred2a, invite)) = th.issue_invite(&cred2); - let (_, bob_cred) = th.redeem_invite(&invite); - th.advance_days(28); - let (_, _) = th.level_up(&bob_cred); - let (_, cred3) = th.level_up(&cred2a); - credentials.push(cred3); - } - println!("\n***START: {}*3*2 BUCKETS 100***\n", x); - block_bridges(&mut th, 100, credentials); - } -} - -/// Blocks a percentage of the bridges for the passed Test Harness -/// excluding the hot spare buckets as they will not have been handed out. -/// The logic assumes hot spare buckets are appended to the end of the bridge_table -/// bucket list. - -fn block_bridges(th: &mut TestHarness, percentage: usize, credentials: Vec) { - let blockable_num = th.ba.bridge_table.buckets.len() - - th.ba.bridge_table.spares.len() - - th.bdb.openinv_buckets.len(); - let blockable_range = th.ba.bridge_table.buckets.len() - th.ba.bridge_table.spares.len(); - let to_block: usize = blockable_num * percentage / 100; - let mut block_index: HashSet = HashSet::new(); - let mut rng = rand::thread_rng(); - - while block_index.len() < to_block { - let rand_num = rng.gen_range(0, blockable_range); - if !th.bdb.openinv_buckets.contains(&(rand_num as u32)) { - block_index.insert(rand_num); - } - } - - for index in block_index { - let b0 = th.ba.bridge_table.buckets[index][0]; - let b1 = th.ba.bridge_table.buckets[index][1]; - let b2 = th.ba.bridge_table.buckets[index][2]; - th.ba.bridge_unreachable(&b0, &mut th.bdb); - th.ba.bridge_unreachable(&b1, &mut th.bdb); - th.ba.bridge_unreachable(&b2, &mut th.bdb); - } - - let mut req_size: Vec = Vec::new(); - let mut resp_size: Vec = Vec::new(); - let mut req_time: Vec = Vec::new(); - let mut resp_time: Vec = Vec::new(); - let mut resp_handle_time: Vec = Vec::new(); - let mut red_req_size: Vec = Vec::new(); - let mut red_resp_size: Vec = Vec::new(); - let mut red_req_time: Vec = Vec::new(); - let mut red_resp_time: Vec = Vec::new(); - let mut red_resp_handle_time: Vec = Vec::new(); - for cred in credentials { - let (id, key) = bridge_table::from_scalar(cred.bucket).unwrap(); - let encbuckets = th.ba.enc_bridge_table(); - let bucket = - bridge_table::BridgeTable::decrypt_bucket(id, &key, &encbuckets[id as usize]).unwrap(); - - let mut count = 0; - for bridge_line in &bucket.0 { - if th.ba.bridge_table.reachable.contains_key(bridge_line) { - count += 1; - } - } - - if count < 2 { - let (perf_stat, migration) = th.check_blockage(&cred); - let (block_perf_stat, _) = th.blockage_migration(&cred, &migration); - req_size.push(perf_stat.req_len as f64); - req_time.push(perf_stat.req_t.as_secs_f64()); - resp_size.push(perf_stat.resp_len as f64); - resp_time.push(perf_stat.resp_t.as_secs_f64()); - resp_handle_time.push(perf_stat.resp_handle_t.as_secs_f64()); - red_req_size.push(block_perf_stat.req_len as f64); - red_req_time.push(block_perf_stat.req_t.as_secs_f64()); - red_resp_size.push(block_perf_stat.resp_len as f64); - red_resp_time.push(block_perf_stat.resp_t.as_secs_f64()); - red_resp_handle_time.push(block_perf_stat.resp_handle_t.as_secs_f64()); - } - } - - println!("\n----CHECK-BLOCKAGE-{}----\n", percentage); - print_stats_test_results(req_size, req_time, resp_size, resp_time, resp_handle_time); - - println!("\n----BLOCKAGE-MIGRATION-{}----\n", percentage); - print_stats_test_results( - red_req_size, - red_req_time, - red_resp_size, - red_resp_time, - red_resp_handle_time, - ); -} - fn print_test_results(perf_stat: PerfStat) { println!("Request size = {:?} bytes", perf_stat.req_len); println!("Request time = {:?}", perf_stat.req_t); println!("Response size = {:?} bytes", perf_stat.resp_len); println!("Response time = {:?}", perf_stat.resp_t); println!("Response handle time = {:?}", perf_stat.resp_handle_t); -} - -//fn print_time_test_results(perf_stat: PerfStat) { -// println!("Request time = {:?}", perf_stat.req_t); -// println!("Response time = {:?}", perf_stat.resp_t); -// println!("Response handle time = {:?}", perf_stat.resp_handle_t); -//} - -fn print_stats_test_results( - req_size: Vec, - req_time: Vec, - resp_size: Vec, - resp_time: Vec, - resp_handle_time: Vec, -) { - let mean_req_size = if req_size.len() > 0 { - mean(&req_size) - } else { - 0.0 - }; - let req_std_dev = if req_size.len() > 1 { - standard_deviation(&req_size, Some(mean_req_size)) - } else { - 0.0 - }; - let mean_req_time = if req_time.len() > 0 { - mean(&req_time) - } else { - 0.0 - }; - let req_time_std_dev = if req_time.len() > 1 { - standard_deviation(&req_time, Some(mean_req_time)) - } else { - 0.0 - }; - let mean_resp_size = if resp_size.len() > 0 { - mean(&resp_size) - } else { - 0.0 - }; - let resp_std_dev = if resp_size.len() > 1 { - standard_deviation(&resp_size, Some(mean_resp_size)) - } else { - 0.0 - }; - let mean_resp_time = if resp_time.len() > 0 { - mean(&resp_time) - } else { - 0.0 - }; - let resp_time_std_dev = if resp_time.len() > 1 { - standard_deviation(&resp_time, Some(mean_resp_time)) - } else { - 0.0 - }; - let mean_resp_handle_time = if resp_handle_time.len() > 0 { - mean(&resp_handle_time) - } else { - 0.0 - }; - let resp_handle_time_std_dev = if resp_handle_time.len() > 1 { - standard_deviation(&resp_handle_time, Some(mean_resp_handle_time)) - } else { - 0.0 - }; - - println!("Average request size = {} bytes", mean_req_size); - println!("Request size standard deviation = {} bytes", req_std_dev); - println!( - "Average request time = {:?}", - Duration::from_secs_f64(mean_req_time) - ); - println!( - "Request time standard deviation = {:?}", - Duration::from_secs_f64(req_time_std_dev) - ); - println!("Average response size = {} bytes", mean_resp_size); - println!("Response standard deviation = {} bytes", resp_std_dev); - println!( - "Average response time = {:?}", - Duration::from_secs_f64(mean_resp_time) - ); - println!( - "Response time standard deviation = {:?}", - Duration::from_secs_f64(resp_time_std_dev) - ); - println!( - "Average response handling time = {:?}", - Duration::from_secs_f64(mean_resp_handle_time) - ); - println!( - "Response handling time standard deviation = {:?}", - Duration::from_secs_f64(resp_handle_time_std_dev) - ); -} +} \ No newline at end of file