-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
9,627 additions
and
1,583 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Analysis of the CID pinging phase\n", | ||
"\n", | ||
" " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"## Import dependencies\n", | ||
"import sqlalchemy as sa\n", | ||
"import pandas as pd\n", | ||
"import seaborn as sns\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"## DB Credentials\n", | ||
"HOST=\"localhost\"\n", | ||
"PORT=\"5433\"\n", | ||
"DB=\"hoarder_test\"\n", | ||
"USER=\"user\"\n", | ||
"PASSWD=\"password\"\n", | ||
"\n", | ||
"# Connecte with the DB\n", | ||
"engine = sa.create_engine(f'postgresql://{USER}:{PASSWD}@{HOST}:{PORT}/{DB}')\n", | ||
"\n", | ||
"## plotting style\n", | ||
"fig_size= (7,4)\n", | ||
"sns.set_context(\"talk\", font_scale=1)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"## get the median time of each fetch time\n", | ||
"\n", | ||
"sql_query=\"\"\"\n", | ||
" SELECT \n", | ||
" cid_hash,\n", | ||
" ping_round, \n", | ||
" fetch_time\n", | ||
" FROM fetch_results\n", | ||
" ORDER BY ping_round;\n", | ||
"\"\"\"\n", | ||
"ping_rounds = pd.read_sql_query(sql_query, engine)\n", | ||
"\n", | ||
"avg_fetcht = ping_rounds.groupby(\"ping_round\").mean()\n", | ||
"hours_dist = avg_fetcht[\"fetch_time\"].to_numpy()\n", | ||
"\n", | ||
"hours_dist = (hours_dist - hours_dist[0]) / 3600\n", | ||
"print(hours_dist)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"## Get the active peers distribution per ping_round\n", | ||
"\n", | ||
"sql_query = \"\"\"\n", | ||
"\tSELECT \n", | ||
"\t\tping_round,\n", | ||
"\t\tconn_error,\n", | ||
"\t\tcount(conn_error) as error_count\n", | ||
"\tFROM ping_results\n", | ||
"\tGROUP BY ping_round, conn_error\n", | ||
"\tORDER BY ping_round, conn_error;\n", | ||
"\"\"\"\n", | ||
"\n", | ||
"error_dists = pd.read_sql_query(sql_query, engine)\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"# plot\n", | ||
"pv_table = error_dists.pivot(index=[\"ping_round\"], columns=\"conn_error\", values=\"error_count\")\n", | ||
"pv_table = pv_table.fillna(0)\n", | ||
"aux = pd.DataFrame(pv_table.to_records())\n", | ||
"\n", | ||
"print(aux)\n", | ||
"\n", | ||
"aux = aux.drop(\"ping_round\", axis=1) \n", | ||
"## Make a boxplot with the distribution\n", | ||
"aux.plot()\n", | ||
"plt.xlabel(\"Time Since Publication (Hours)\")\n", | ||
"plt.ylabel(\"Error Count\")\n", | ||
"plt.legend(loc=\"center left\", bbox_to_anchor=(1, 0, 0.5, 1), prop={'size': 16})\n", | ||
"plt.show()\n", | ||
"\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"engine.dispose()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3.8.10 ('plotter')", | ||
"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.10.8 (main, Nov 14 2022, 00:00:00) [GCC 12.2.1 20220819 (Red Hat 12.2.1-2)]" | ||
}, | ||
"orig_nbformat": 4, | ||
"vscode": { | ||
"interpreter": { | ||
"hash": "27c6d93b683c7a1975bfd893e997da1d087883bf6b96d34d1e63ecc137ac54d0" | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Binary file not shown.
Oops, something went wrong.