Commit 3b23a851 authored by Renato Caminha Juaçaba Neto's avatar Renato Caminha Juaçaba Neto 🙂
Browse files

myclean

parent c868b000
......@@ -22,4 +22,4 @@ clean:
distclean:
./waf distcleain
myclean:
rm *.trace parameters.txt *.err *.out
rm *.trace parameters.txt *.err *.out 2> /dev/null
......@@ -71,7 +71,7 @@ statistics_dataframes = map(read_statistics, sim_folders)
def replace_values(val):
replacements = {
"Random Trees": "Transformation overlay",
"Random Trees": "Multi-domain",
"Direct Subscriptions": "Conventional NDN"
}
if isinstance(val, str): val = val.strip()
......@@ -98,6 +98,7 @@ fullL3DF = pd.concat(statistics_dataframes_with_params[2], ignore_index=True, so
fullConsumerStatsDF = pd.concat(statistics_dataframes_with_params[3], ignore_index=True, sort=True)
fullStreamDelaysDF = pd.concat(statistics_dataframes_with_params[4], ignore_index=True, sort=True)
fullStreamDistancesDF = pd.concat(statistics_dataframes_with_params[5], ignore_index=True, sort=True)
fullDataSpreadDF = pd.concat(statistics_dataframes_with_params[6], ignore_index=True, sort=True)
node_type_order = ("Consumer",
"Border Router")#,
......@@ -113,7 +114,7 @@ node_type_order = ("Consumer",
# scenarioOrder = ("NasArch", "PullEverything", "PushEverything")
# scenarioOrder = ("Random Trees", "Direct Subscriptions")
scenarioOrder = ("Transformation overlay", "Conventional NDN")
scenarioOrder = ("Multi-domain", "Conventional NDN")
violin_params = {'inner': "box", 'bw': 'scott', 'scale': 'width'}
......@@ -167,9 +168,10 @@ for n, g in aggMaskedData.groupby('NodeType'):
# # maskedData.loc[:, 'NodeType'].cat.remove_unused_categories(inplace=True)
# aggMaskedData = maskedData.groupby(["nConsumers", "AppScenario", "seed"], as_index=False).sum()
#
# # single_relplot(title="Sum of data in all content stores", xlabel="Number of consumers", ylabel="Megabytes",
# # single_pdf=pdf, kind="line", data=aggMaskedData, y="Packets", x="nConsumers", hue_order=scenarioOrder,
# # style="AppScenario", hue="AppScenario")
#
single_relplot(title="Sum of data in all content stores", xlabel="Number of consumers", ylabel="Megabytes",
single_pdf=pdf, kind="line", data=aggMaskedData, y="Packets", x="nConsumers", hue_order=scenarioOrder,
style="AppScenario", hue="AppScenario")
#
# single_catplot(title="Sum of data in all content stores", xlabel="Number of consumers", ylabel="Megabytes",
# kind="violin", data=aggMaskedData, y="Packets", x="nConsumers", hue="AppScenario",
......@@ -191,9 +193,29 @@ aggMaskedData = maskedData.loc[:, ["Node", "NodeType", "AppScenario", "nConsumer
# single_pdf=pdf, kind="line", data=aggMaskedData, style="NodeType", row="AppScenario", row_order=scenarioOrder,
# hue_order=node_type_order, hue="NodeType", x="nConsumers", y="KilobytesRaw")
single_catplot(title="Border router traffic load", xlabel="Number of consumers", ylabel="Data transmitted (KB)",
single_pdf=pdf, kind="violin", data=aggMaskedData, hue="AppScenario", hue_order=scenarioOrder,
g = single_catplot(title="Total Border router traffic load", xlabel="Number of consumers", ylabel="Data transmitted (KB)",
single_pdf=pdf, kind="violin", data=aggMaskedData, hue="AppScenario", hue_order=scenarioOrder,
y="KilobytesRaw", x="nConsumers", **violin_params, facet_kws=dict(subplot_kws=dict(yscale='log')))
mask = (fullL3DF.Type == "OutData") & \
(fullL3DF.FaceDescr.str.startswith("netdev")) & \
(fullL3DF.NodeType == 'Border Router')
maskedData = fullL3DF.loc[mask, ["AppScenario", "nConsumers", "seed", "KilobytesRaw"]]
aggMaskedData = maskedData.groupby(["AppScenario", "nConsumers", "seed"]).sum()
mask2 = (fullL3DF.Type == "InData") & \
(fullL3DF.FaceDescr.str.startswith("netdev")) & \
(fullL3DF.NodeType == 'Consumer')
maskedData2 = fullL3DF.loc[mask2, ["AppScenario", "nConsumers", "seed", "KilobytesRaw"]]
aggMaskedData2 = maskedData2.groupby(["AppScenario", "nConsumers", "seed"]).sum()
correctedTrafficData = (aggMaskedData - aggMaskedData2).reset_index()
correctedTrafficData['KilobytesRaw'] /= 20
single_catplot(title="Average core border router traffic load", xlabel="Number of consumers", ylabel="Data transmitted (KB)",
single_pdf=pdf, kind="violin", data=correctedTrafficData, hue="AppScenario", hue_order=scenarioOrder,
y="KilobytesRaw", x="nConsumers", **violin_params)
#, hue="NodeType", hue_order=node_type_order)
# duo_catplot(title="Border router traffic load", xlabel="Number of consumers", ylabel="Data transmitted (KB)",
......@@ -289,8 +311,18 @@ logger.info("Plotting stream delay distances...")
maskedData = fullStreamDistancesDF.loc[:, ['AppScenario', 'seed', 'HopCount']]
avgData = maskedData.groupby(['AppScenario', 'seed'], as_index=False).mean()
single_catplot(title='Distance between consumers and producers', xlabel="", ylabel="Hop count",
single_pdf=pdf, kind='violin', data=avgData, x='AppScenario', y='HopCount', **violin_params)
single_catplot(title='Distance between consumers and producers', xlabel="", ylabel="Hop count", single_pdf=pdf,
kind='violin', data=avgData, x='AppScenario', order=scenarioOrder, y='HopCount', **violin_params)
logger.info("Plotting data spreads...")
maskedData = fullDataSpreadDF.loc[:, ['AppScenario', 'nConsumers', 'seed', 'Count']]
avgData = maskedData.groupby(['AppScenario', 'nConsumers', 'seed'], as_index=False).mean()
single_catplot(title='spread of data sources among the network', xlabel="", ylabel="Data spread", single_pdf=pdf,
kind='violin', data=avgData, x='nConsumers', hue='AppScenario', hue_order=scenarioOrder,
y='Count', **violin_params, facet_kws=dict(subplot_kws=dict(yscale='log')))
logger.info("Done plotting!!!")
......
#!/usr/bin/python3
import argparse
from glob import glob
from plot_utils import *
from nas_utils import setup_logger
from os import path
from sys import stderr, exit, platform
import pandas as pd
from itertools import starmap
import seaborn as sb
from matplotlib.backends.backend_pdf import PdfPages
from subprocess import Popen, PIPE
sb.set(context='paper', font_scale=1.8, style='ticks', palette='Paired',
rc={'lines.linewidth': 1.5, 'lines.markersize': 10})
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', -1)
parser = argparse.ArgumentParser(description='This script plots data from simulations')
parser.add_argument('paths', metavar='Experiment path', type=str, nargs=argparse.REMAINDER,
help='Root folders to search for traces')
#
parser.add_argument('--log_to_file', action='store_true', help="Output log messages to file")
#
parser.add_argument('--loglevel', type=str, choices=['DEBUG', 'INFO', 'WARNING'], default='INFO',
help="Level of verbosity used in the log")
parser.add_argument('--plot-l3-interests', '--push-everything', '--interests', dest="l3_type", action="store_const",
const="OutInterests", help="Use OutInterests instead of OutData for l3 traffic", default="OutData")
parser.add_argument('--dont-open-pdf', '--no-open', '--no-show', dest="should_open_pdf", action="store_false",
default=True, help="Should open pdf viewer?")
parser.add_argument('--single-pdf', dest="single_pdf", action="store_true", default=False,
help="Should create a single multi page pdf")
parser.add_argument('--cat-type', dest='catType', default="violin", type=str,
help="What type of plot should be done for catplots")#,
#choices=["point", "bar", "strip", "violin", "box", "violin", "boxen", "swarm"])
params = parser.parse_args()
logger = setup_logger("PlotMultipleRuns", params.loglevel, params.log_to_file)
if len(params.paths) != 0:
if all(map(path.isdir, params.paths)) is not True:
print("One of the params is not a directory", file=stderr)
exit(1)
sim_folders = list()
for folder in params.paths:
sim_folders += glob(path.join(folder, '**', 'seed=*'), recursive=True)
else:
sim_folders = glob(path.join('.', '**', 'seed=*'), recursive=True)
def is_finished_sim_folder(f: str):
return path.isfile(path.join(f, 'consumer-metrics.trace'))
sim_folders = list(filter(is_finished_sim_folder, sim_folders))
logger.debug("Found %d simulation folders.", len(sim_folders))
logger.info("Gathering data from simulations...")
statistics_dataframes = map(read_statistics, sim_folders)
def replace_value(val):
if isinstance(val, str): val = val.strip()
if val == "Private Domains":
return "Transformation overlay"
elif val == "Direct Subscriptions":
return "Conventional NDN subscriptions"
elif val == "Same":
return "Equal"
elif val == "Compatible":
return "Subset"
elif val == "Incompatible":
return "Superset"
else:
return val
def append_params_to_dataframe(params, *datasets):
for name, value in params.items():
for dataset in datasets:
if dataset is not None:
dataset.insert(0, name, replace_value(value))
return datasets
statistics_dataframes_with_params = list(map(list, zip(*starmap(append_params_to_dataframe, statistics_dataframes))))
fullCsDF = pd.concat(statistics_dataframes_with_params[0], ignore_index=True, sort=True)
fullStreamHitsDF = pd.concat(statistics_dataframes_with_params[1], ignore_index=True, sort=True)
fullL3DF = pd.concat(statistics_dataframes_with_params[2], ignore_index=True, sort=True)
fullConsumerStatsDF = pd.concat(statistics_dataframes_with_params[3], ignore_index=True, sort=True)
fullStreamDelaysDF = pd.concat(statistics_dataframes_with_params[4], ignore_index=True, sort=True)
node_type_order = ("Consumer", "Border Router", # "Consumer Router",
# "Consumer Mediator",
# "Broker Mediator",
# "Broker Mediator 1",
# "Broker Mediator 2",
# "Broker Mediator 3",
# "Producer Mediator",
# "Producer Router",
"Producer")
scenarioOrder = ("Transformation overlay", "Conventional NDN subscriptions")
if params.single_pdf:
pdf = PdfPages("graphs-var-nsystems.pdf")
else:
pdf = None
logger.info("Plotting content store graphs...")
mask = (fullCsDF.Type.str.contains("CacheSizeByte")) & (fullCsDF.NodeType.str.contains('Border Router'))
maskedData = fullCsDF.loc[mask, ['Node', 'nSystems', 'Packets', 'seed']]
single_catplot(title="Volume of Data in border routers' content store", ylabel='Content Store Size (KB)', xlabel='Number of domains',
single_pdf=pdf, kind='violin', x='nSystems', y='Packets', data=maskedData, scale='width', cut=0)
logger.info("Plotting L3 graphs...")
mask = (fullL3DF.Type == "OutData") & (fullL3DF.FaceDescr.str.startswith("netdev")) & \
(fullL3DF.KilobytesRaw != 0) & \
(fullL3DF.NodeType.str.contains("Border Router"))
maskedData = fullL3DF.loc[mask, ['nSystems', "Node", "seed", "KilobytesRaw"]]
aggData = maskedData.groupby(['nSystems', "Node", "seed"], as_index=False).sum()
single_catplot(title="Border routers data transmissions", ylabel='Transmitted data (KB)', xlabel='Number of systems',
single_pdf=pdf, kind='violin', x='nSystems', y='KilobytesRaw', data=aggData, scale='width', cut=0)
logger.info("Plotting consumer metrics...")
mask = (fullConsumerStatsDF.Metric.str.contains("InterestSatisfaction"))
maskedData = fullConsumerStatsDF.loc[mask, ['Value', 'seed']]
avgMaskedData = maskedData.groupby('seed', as_index=False).mean()
single_catplot(title="Interest Satisfaction", ylabel='Interest Satisfaction (%)', data=avgMaskedData, single_pdf=pdf,
xlabel='', x=None, sharey=True, kind='violin', y='Value', facet_kws={'ylim': (0, 110)})
mask = (fullConsumerStatsDF.Metric.str.contains("FirstDataDelayNorm"))
maskedData = fullConsumerStatsDF.loc[mask, ['nSystems', 'Value']]
single_catplot(title="Normalized First Data Delay", ylabel='Normalized Delay', y='Value', x="nSystems",
xlabel='Number of Systems', single_pdf=pdf, kind='violin', data=maskedData, scale='width', cut=0)
logger.info("Done plotting!!!")
if params.single_pdf:
pdf.close()
if params.single_pdf and params.should_open_pdf:
pdf_viewer = ''
if platform.startswith('linux'):
pdf_viewer = 'evince'
elif platform.startswith('darwin'):
pdf_viewer = 'open'
elif platform.startswith('win'):
pdf_viewer = 'start'
if pdf_viewer:
Popen([pdf_viewer, "graphs.pdf"], stderr=PIPE, stdout=PIPE)
......@@ -43,7 +43,7 @@ def get_node_type(node_name):
def read_statistics(dir_path='', read_l3_dataset=True, read_cs_dataset=True, read_stream_hits_dataset=True,
read_consumer_dataset=True, read_delay_metrics=True, read_stream_distances=True):
read_consumer_dataset=True, read_delay_metrics=True, read_stream_distances=True, read_data_spread=True):
logger = logging.getLogger('ReadStatistics')
logger.info("Starting")
......@@ -111,9 +111,16 @@ def read_statistics(dir_path='', read_l3_dataset=True, read_cs_dataset=True, rea
else:
stream_distances = None
### Data spread
if read_data_spread and path.isfile(path.join(dir_path, "data-spread.trace")):
logger.info("Reading data spread")
data_spread = pd.read_csv(path.join(dir_path, "data-spread.trace"), sep="\s+")
else:
data_spread = None
logger.info("Finished reading statistics")
return sim_parameters, cs_dataset, stream_hits_dataset, l3_dataset, \
consumer_dataset, stream_delays, stream_distances
consumer_dataset, stream_delays, stream_distances, data_spread
def get_iqr_outliers(series):
......@@ -123,15 +130,15 @@ def get_iqr_outliers(series):
filled_markers = ('o', 'd', '^', 'v', 's', '<', '>', '*', '8', 'p', 'h', 'H', 'D', 'P', 'X')
sizingParams = {
'height': 5,
'aspect': 1,
}
wideSizingParams = {
**sizingParams,
'aspect': 1.4,
}
# sizingParams = {
# 'height': 5,
# 'aspect': 1,
# }
#
# wideSizingParams = {
# **sizingParams,
# 'aspect': 1.1,
# }
lineParams = {
'markers': filled_markers,
......@@ -156,7 +163,8 @@ def single_relplot(xlabel, ylabel, title=None, single_pdf=None, **plot_params):
if 'sharey' in plot_params:
sharey = plot_params['sharey']
del plot_params['sharey']
unified_params = {**sizingParams, **lineParams, 'facet_kws': {'sharex': sharex, 'sharey': sharey}, **plot_params}
# unified_params = {**sizingParams, **lineParams, 'facet_kws': {'sharex': sharex, 'sharey': sharey}, **plot_params}
unified_params = {**lineParams, 'facet_kws': {'sharex': sharex, 'sharey': sharey}, **plot_params}
graph = sb.relplot(**unified_params)
graph.set_xlabels(xlabel)
graph.set_ylabels(ylabel)
......@@ -179,7 +187,8 @@ def single_relplot(xlabel, ylabel, title=None, single_pdf=None, **plot_params):
def single_catplot(xlabel, ylabel, title=None, single_pdf=None, **plot_params):
unified_params = {**wideSizingParams, **plot_params}
# unified_params = {**wideSizingParams, 'sharex': False, 'sharey': False, **plot_params}
unified_params = {'sharex': False, 'sharey': False, **plot_params}
graph = sb.catplot(**unified_params)
graph.set_xlabels(xlabel)
graph.set_ylabels(ylabel)
......@@ -208,7 +217,8 @@ def duo_relplot(xlabel, ylabel, title=None, single_pdf=None, **plot_params):
if 'sharey' in plot_params:
sharey = plot_params['sharey']
del plot_params['sharey']
unified_params = {**sizingParams, **lineParams, 'facet_kws': {'sharex': sharex, 'sharey': sharey}, **plot_params}
# unified_params = {**sizingParams, **lineParams, 'facet_kws': {'sharex': sharex, 'sharey': sharey}, **plot_params}
unified_params = {**lineParams, 'facet_kws': {'sharex': sharex, 'sharey': sharey}, **plot_params}
graph = sb.relplot(**unified_params)
graph.set_xlabels(xlabel)
graph.set_ylabels(ylabel)
......@@ -231,7 +241,8 @@ def duo_relplot(xlabel, ylabel, title=None, single_pdf=None, **plot_params):
def duo_catplot(xlabel, ylabel, title=None, single_pdf=None, **plot_params):
unified_params = {**wideSizingParams, 'sharex': False, 'sharey': False, **plot_params}
# unified_params = {**wideSizingParams, 'sharex': False, 'sharey': False, **plot_params}
unified_params = {'sharex': False, 'sharey': False, **plot_params}
graph = sb.catplot(**unified_params)
graph.set_xlabels(xlabel)
graph.set_ylabels(ylabel)
......@@ -260,7 +271,8 @@ def trio_relplot(xlabel, ylabel, title=None, single_pdf=None, **plot_params):
if 'sharey' in plot_params:
sharey = plot_params['sharey']
del plot_params['sharey']
unified_params = {**sizingParams, **lineParams, 'facet_kws': {'sharex': sharex, 'sharey': sharey}, **plot_params}
# unified_params = {**sizingParams, **lineParams, 'facet_kws': {'sharex': sharex, 'sharey': sharey}, **plot_params}
unified_params = {**lineParams, 'facet_kws': {'sharex': sharex, 'sharey': sharey}, **plot_params}
graph = sb.relplot(**unified_params)
graph.set_xlabels(xlabel)
graph.set_ylabels(ylabel)
......@@ -283,7 +295,8 @@ def trio_relplot(xlabel, ylabel, title=None, single_pdf=None, **plot_params):
def trio_catplot(xlabel, ylabel, title=None, single_pdf=None, **plot_params):
unified_params = {**wideSizingParams, 'sharex': False, 'sharey': False, **plot_params}
# unified_params = {**wideSizingParams, 'sharex': False, 'sharey': False, **plot_params}
unified_params = {'sharex': False, 'sharey': False, **plot_params}
graph = sb.catplot(**unified_params)
graph.set_xlabels(xlabel)
graph.set_ylabels(ylabel)
......
......@@ -74,7 +74,8 @@ if params.singlecpu:
runners = Pool(1, initializer=nas_utils.runSimulationWorkerInitializer, initargs=(progressCounter,))
else:
# runners = Pool(initializer=nas_utils.runSimulationWorkerInitializer, initargs=(progressCounter,))
runners = Pool(int(mp.cpu_count()/2), initializer=nas_utils.runSimulationWorkerInitializer, initargs=(progressCounter,))
# runners = Pool(int(mp.cpu_count()/2), initializer=nas_utils.runSimulationWorkerInitializer, initargs=(progressCounter,))
runners = Pool(5, initializer=nas_utils.runSimulationWorkerInitializer, initargs=(progressCounter,))
params.expanded_sim_params = nas_utils.expand_sim_parameters(params.sim_params)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment