Skip to content

Commit

Permalink
merge CLI-refactoring to dev
Browse files Browse the repository at this point in the history
  • Loading branch information
cortze committed Jan 12, 2023
2 parents aaec5e0 + 5b8a264 commit bda5745
Show file tree
Hide file tree
Showing 53 changed files with 9,627 additions and 1,583 deletions.
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ build/
data/*

# Dismiss python cached stuff and venv
__pycache__/
.ipynb_checkpoints/
analyzer/.ipynb_checkpoints/
analyzer/venv/
logs/

# Igonore the .vscode configuration
# Ignore the .vscode configuration
.vscode

#Ignore .idea
.idea

# TODO: update to make file and build folder
dbs
dbs
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ install:

dependencies:
$(GIT_SUBM) update --init
cd go-libp2p-kad-dht && git checkout cid-hoarder
cd go-libp2p-kad-dht && git checkout origin/cid-hoarder


clean:
Expand Down
174 changes: 138 additions & 36 deletions README.md

Large diffs are not rendered by default.

230 changes: 217 additions & 13 deletions analyzer/cid_publication_phase.ipynb

Large diffs are not rendered by default.

142 changes: 142 additions & 0 deletions analyzer/error_distribution.ipynb
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 added analyzer/log/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Loading

0 comments on commit bda5745

Please sign in to comment.