{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# X-Lap in Action" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Imports" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import logging\n", "logger = logging.getLogger()\n", "logger.setLevel(logging.DEBUG)\n", "from ipywidgets import interact, interactive, fixed, interact_manual\n", "import ipywidgets as widgets\n", "from xlap.parse import evaluate, evaluate_side, parse_config\n", "import xlap.analyse.jitter as jitter\n", "from xlap.analyse.cdf import multi_cdf\n", "from xlap.analyse.regress import linear as linear_regression\n", "from xlap.analyse.trace import traces\n", "from xlap.analyse.correlation import correlation, multi_correlation\n", "from xlap.analyse.latency import analyse\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import copy\n", "%matplotlib inline\n", "colors = [\"#E69F00\", \"#009E73\", \"#56B4E9\", \"#CC79A7\", \"#D55E00\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data Retrieval" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "config = parse_config()\n", "data_files = {\n", " \"sender\": \"rtn2018/20180417_testbed/\",\n", " \"receiver\": \"rtn2018/20180417_testbed/\"\n", "}\n", "original1 = evaluate(data_files[\"sender\"] + \"sender-1000000.csv\", data_files[\"receiver\"] + \"receiver-1000000.csv\", config=config, kind=0)\n", "original1.name = \"1GHz\"\n", "original2 = evaluate(data_files[\"sender\"] + \"sender-2000000.csv\", data_files[\"receiver\"] + \"receiver-2000000.csv\", config=config, kind=0)\n", "original2.name = \"2GHz\"\n", "original3 = evaluate(data_files[\"sender\"] + \"sender-3000000.csv\", data_files[\"receiver\"] + \"receiver-3000000.csv\", config=config, kind=0)\n", "original3.name = \"3GHz\"\n", "dfs = [original1, original2, original3]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Traces" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "traces(original1, config, global_xaxis=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Jitter Analysis" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def multi_trace_jitter(dfs, config):\n", " for df in dfs:\n", " print(\"############################ {} ############################\".format(df.name))\n", " jitter.trace_jitter(df, config=config, threshold=200)\n", " \n", "multi_trace_jitter(dfs, config)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## CDFs" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cfg = copy.deepcopy(config)\n", "d = cfg[\"durations\"]\n", "\n", "l=(\"Decoding\",\"ReceiverIPC\",\"HandlePacket\", \"Feedback\", \"SenderIPC\",\"SenderEnqueued\",\"Enqueue\")\n", "for e in l:\n", " if e in l:\n", " del d[e]\n", "\n", "multi_cdf(dfs, cfg, colors=colors)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Correlation" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "multi_correlation(dfs, config, colors=colors, figsize=(3.0,2.0), cols=4)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Latency Criticality" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "d = analyse(original1, config)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Correlations" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "d.corr.sort_values(ascending=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Control Flow Graph" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "d.cfg" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Kolmogorov\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from scipy import stats\n", "from xlap.analyse.util import extract_durations\n", "import numpy as np\n", "\n", "def timing_behaviour(df1, df2, config, confidence=0.9):\n", " durations = [x + \"_D\" for x in extract_durations(config)]\n", " \n", " norm = lambda x: x / np.max(x)\n", " \n", " for duration in durations:\n", " rvs1 = norm(df1[duration])\n", " rvs2 = norm(df2[duration])\n", " stat, pvalue = stats.ks_2samp(rvs1, rvs2)\n", " result = \"CANNOT REJECT\"\n", " if pvalue < 1 - confidence:\n", " result = \"REJECT\"\n", " print(duration.ljust(20), \"{:.6f}\".format(pvalue), result, sep=\"\\t\\t\")\n", "\n", "timing_behaviour(original1, original2, config)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timing_behaviour(original1, original3, config)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timing_behaviour(original2, original3, config)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.8" }, "widgets": { "state": { "df95aa8c42974dfeaf8e0a2c05100645": { "views": [ { "cell_index": 6 } ] } }, "version": "1.2.0" } }, "nbformat": 4, "nbformat_minor": 2 }