Skip to content

Commit

Permalink
✨ (analysis) adjust grid + generate container replica graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias-Pe committed Jul 23, 2024
1 parent 796d425 commit 6a7e04e
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 56 additions & 2 deletions loadtesting/notebooks/locust.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"import pytz\n",
"import plotly.graph_objects as go\n",
"import os\n",
"from matplotlib.ticker import ScalarFormatter, LogLocator"
"import matplotlib.dates as mdates"
],
"id": "f546290dcd056f13",
"outputs": [],
Expand All @@ -21,7 +21,7 @@
"id": "3d6de811535875d3",
"metadata": {},
"source": [
"basedir = \"../data/baseapp/2024-07-15/16-18/\"\n",
"basedir = \"../data/baseapp/2024-07-15/10-12/\"\n",
"outputdir = basedir+\"output/\"\n",
"os.makedirs(outputdir, exist_ok=True)\n",
"locust_data_history_file = basedir + \"data_stats_history.csv\"\n",
Expand Down Expand Up @@ -153,6 +153,8 @@
"ax1.tick_params(axis='y')\n",
"ax1.legend(loc='upper left')\n",
"ax1.grid(True)\n",
"ax1.xaxis.set_major_locator(mdates.MinuteLocator(interval=5))\n",
"ax1.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))\n",
"\n",
"# Secondary Y-Axis\n",
"ax2 = ax1.twinx()\n",
Expand Down Expand Up @@ -182,6 +184,8 @@
"ax1.tick_params(axis='y')\n",
"ax1.legend(loc='upper left')\n",
"ax1.grid(True)\n",
"ax1.xaxis.set_major_locator(mdates.MinuteLocator(interval=5))\n",
"ax1.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))\n",
"\n",
"# Secondary Y-Axis\n",
"ax2 = ax1.twinx()\n",
Expand Down Expand Up @@ -250,6 +254,56 @@
"outputs": [],
"execution_count": null
},
{
"metadata": {},
"cell_type": "code",
"source": [
"# Load data from CSV\n",
"containers_data_file = \"../data/baseapp/2024-07-15/containers.csv\"\n",
"containers_df = pd.read_csv(containers_data_file)\n",
"\n",
"# Parse the time column and set it as the index\n",
"containers_df['Time'] = pd.to_datetime(containers_df['Time'])\n",
"containers_df.set_index('Time', inplace=True)\n",
"\n",
"# Format column names to display only container names\n",
"containers_df.columns = [col.split('=')[1].strip(' \"{}') for col in containers_df.columns]\n",
"\n",
"def plot_data(start_time, end_time):\n",
" # Filter data within the specified time range\n",
" mask = (containers_df.index >= start_time) & (containers_df.index <= end_time)\n",
" filtered_data = containers_df.loc[mask]\n",
" \n",
" # Plotting\n",
" plt.figure(figsize=(12, 8))\n",
" \n",
" for column in filtered_data.columns:\n",
" if column.endswith(\"service\") or column == \"gateway\":\n",
" plt.plot(filtered_data.index, filtered_data[column], label=column, linewidth=2.0)\n",
" else:\n",
" plt.plot(filtered_data.index, filtered_data[column], label='_nolegend_', linestyle='--') \n",
" \n",
" plt.xlabel('Time')\n",
" plt.ylabel('Value')\n",
" plt.title('Container Replicas Over Time')\n",
"\n",
" # Add legend for high variability columns only\n",
" plt.legend(loc='best', bbox_to_anchor=(1.05, 1), borderaxespad=0.)\n",
" \n",
" plt.grid(True)\n",
" xticks = pd.date_range(start=start_time, end=end_time, freq='5min') \n",
" plt.xticks(ticks=xticks, labels=[tick.strftime(\"%H:%M\") for tick in xticks], rotation=45)\n",
" plt.tight_layout()\n",
" plt.savefig(outputdir+'plt_container_replicas.png', bbox_inches='tight')\n",
" plt.show()\n",
"\n",
"# Plot data within the specified time range\n",
"plot_data(start_time, end_time)"
],
"id": "f072d2575bf7a131",
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"id": "11e7a30b897c45e7",
Expand Down

0 comments on commit 6a7e04e

Please sign in to comment.