{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d43eeaf8-36c1-49c3-8399-2fe3dc8346b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 54696 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from brokenaxes import brokenaxes\n",
    "import pandas as pd\n",
    "\n",
    "for dark in [True, False]:\n",
    "    if dark:\n",
    "        plt.style.use(\"dark_background\")\n",
    "    else:\n",
    "        plt.style.use(\"default\")\n",
    "\n",
    "    df1 = pd.read_csv(\"latency.native.csv\", header=0)\n",
    "    df2 = pd.read_csv(\"latency.browser.csv\", header=0)\n",
    "\n",
    "    agg1 = df1.groupby(\"latency\")[\"time_total\"].mean().reset_index()\n",
    "    agg2 = df2.groupby(\"latency\")[\"time_total\"].mean().reset_index()\n",
    "\n",
    "    plt.plot(agg1[\"latency\"], agg1[\"time_total\"]/1000.0, label=\"native\")\n",
    "    plt.plot(agg2[\"latency\"], agg2[\"time_total\"]/1000.0, label=\"browser\")\n",
    "\n",
    "    plt.xlim(10, 200)\n",
    "    plt.ylim(0, 13)\n",
    "\n",
    "    # force ticks, otherwise 10 is not displayed\n",
    "    plt.xticks([10] + list(range(25, 201, 25)))\n",
    "\n",
    "    plt.xlabel(\"Latency (msec)\")\n",
    "    plt.ylabel(\"Runtime (sec)\")\n",
    "    plt.title(\"Latency effect on protocol runtime\")\n",
    "    plt.legend(loc=\"upper left\") \n",
    "\n",
    "    plt.grid(True, linestyle=\"--\")\n",
    "\n",
    "    svg_name = \"latency_dark.svg\" if dark else \"latency_light.svg\"\n",
    "\n",
    "    plt.savefig(svg_name, bbox_inches=\"tight\")\n",
    "\n",
    "    plt.show()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "39b91559-3c26-45e1-9348-8fdf2a486122",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.13.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
