Skip to content

Commit

Permalink
benchmarks on aws ec2 complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Souldiv committed Aug 20, 2018
1 parent b1f98a4 commit 814753c
Show file tree
Hide file tree
Showing 19 changed files with 204 additions and 9 deletions.
70 changes: 70 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import matplotlib.pyplot as plt
import seaborn as sns
import psutil
from multiprocessing import Process
import time
import pandas as pd
from pgso.gso import GSO as PGSO
from pgso.test_functions import rosen


def monitor(target, bounds, num_particles, max_iter, costfunc, M):
worker_process = Process(target=target, args=(
M, bounds, num_particles, max_iter, costfunc))
worker_process.start()
p = psutil.Process(worker_process.pid)

# log cpu usage of `worker_process` every 10 ms
cpu_percents = [0.0]
start = time.time()
time_at = []
top_prcnt = []
while worker_process.is_alive():
top = psutil.cpu_percent(percpu=True)
top_prcnt.append(top)
cpu_percents.append(p.cpu_percent())
time_at.append(time.time() - start)
time.sleep(0.01)
worker_process.join()
return cpu_percents, time_at, top_prcnt


def multiple_cpu_plot(top_prcnt, time_at, zoom_range=[], step=1, name='tests'):
cols = list()
for i in range(psutil.cpu_count()):
cols.append('cpu_' + str(i + 1))
df = pd.DataFrame.from_records(top_prcnt, columns=cols)
df['time_at'] = time_at
fig, ax = plt.subplots(figsize=(20, 20), ncols=4, nrows=4)

sns.set_style("dark")
flat_ax = [bx for axs in ax for bx in axs]
for i, sdf in enumerate(flat_ax):
if i >= psutil.cpu_count():
break
if zoom_range != []:
sdf.set_xticks((np.arange(zoom_range[0], zoom_range[1] + 1, step)))
sdf.set_xlim(zoom_range[0], zoom_range[1])
sdf.set_title('cpu_' + str(i + 1))
for i in range(psutil.cpu_count()):
sns.lineplot(x='time_at', y='cpu_' +
str(i + 1), data=df, ax=flat_ax[i])
plt.savefig(name, bbox_inches='tight')


# global settings

# initial starting location [x1,x2...]
initial = [5, 5]

# input bounds [(x1_min,x1_max),(x2_min,x2_max)...]
bounds = [[-1000, 1000], [-1000, 1000]]

num_particles = 75

max_iter = 1500


cpu_percent, time_at, top_prcnt = monitor(
PGSO, bounds, num_particles, max_iter, rosen, 1)
multiple_cpu_plot(top_prcnt, time_at, name='1_CPU_Graph')
59 changes: 59 additions & 0 deletions experiments/.ipynb_checkpoints/aws_ec2_benchmarks-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Benchmarks\n",
"\n",
"This notebook contains the PGSO benchmarks conducted on the amazon ec2 instance using the following specifications:\n",
"\n",
"![Image](Benchmark_Images/benchmark_2.png)\n",
"\n",
"\n",
"## Benchmark for 8 cores spawning 1 process\n",
"![24_1_CPU](Benchmark_Images/1_CPU_Graph.png)\n",
"\n",
"## Benchmark for 8 cores spawning 2 process\n",
"![24_1_CPU](Benchmark_Images/2_CPU_Graph.png)\n",
"\n",
"## Benchmark for 8 cores spawning 4 process\n",
"![24_1_CPU](Benchmark_Images/4_CPU_Graph.png)\n",
"\n",
"## Benchmark for 8 cores spawning 6 process\n",
"![24_1_CPU](Benchmark_Images/6_CPU_Graph.png)\n",
"\n",
"## Benchmark for 8 cores spawning 8 process\n",
"![24_1_CPU](Benchmark_Images/8_CPU_Graph.png)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Binary file added experiments/Benchmark_Images/1_CPU_Graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added experiments/Benchmark_Images/2_CPU_Graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added experiments/Benchmark_Images/4_CPU_Graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added experiments/Benchmark_Images/6_CPU_Graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added experiments/Benchmark_Images/8_CPU_Graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added experiments/Benchmark_Images/benchmark_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 16 additions & 9 deletions experiments/Xeon_Benchmarks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,43 @@
"\n",
"This notebook contains the PGSO benchmarks conducted on the AI devcloud using the following specifications:\n",
"\n",
"![Image](Xeon_Benchmark_Images/benchmark_cpu.png)\n",
"![Image](Benchmark_Images/benchmark_cpu.png)\n",
"\n",
"## Jobs\n",
"\n",
"each individual job was run using *qsub* and through the cli using the online_benchmark script prepared in the root folder of this project\n",
"\n",
"## Benchmark for 24 cores spawning 1 process\n",
"![24_1_CPU](Xeon_Benchmark_Images/24_1_CPU.png)\n",
"![24_1_CPU](Benchmark_Images/24_1_CPU.png)\n",
"\n",
"## Benchmark for 24 cores spawning 2 process\n",
"![24_1_CPU](Xeon_Benchmark_Images/24_2_CPU.png)\n",
"![24_1_CPU](Benchmark_Images/24_2_CPU.png)\n",
"\n",
"## Benchmark for 24 cores spawning 4 process\n",
"![24_1_CPU](Xeon_Benchmark_Images/24_4_CPU.png)\n",
"![24_1_CPU](Benchmark_Images/24_4_CPU.png)\n",
"\n",
"## Benchmark for 24 cores spawning 8 process\n",
"![24_1_CPU](Xeon_Benchmark_Images/24_8_CPU.png)\n",
"![24_1_CPU](Benchmark_Images/24_8_CPU.png)\n",
"\n",
"## Benchmark for 24 cores spawning 12 process\n",
"![24_1_CPU](Xeon_Benchmark_Images/24_12_CPU.png)\n",
"![24_1_CPU](Benchmark_Images/24_12_CPU.png)\n",
"\n",
"## Benchmark for 24 cores spawning 16 process\n",
"![24_1_CPU](Xeon_Benchmark_Images/24_16_CPU.png)\n",
"![24_1_CPU](Benchmark_Images/24_16_CPU.png)\n",
"\n",
"## Benchmark for 24 cores spwaning 20 process\n",
"![24_1_CPU](Xeon_Benchmark_Images/24_20_CPU.png)\n",
"![24_1_CPU](Benchmark_Images/24_20_CPU.png)\n",
"\n",
"## Benchmark for 24 cores spwaning 24 process\n",
"![24_1_CPU](Xeon_Benchmark_Images/24_24_CPU.png)\n"
"![24_1_CPU](Benchmark_Images/24_24_CPU.png)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
59 changes: 59 additions & 0 deletions experiments/aws_ec2_benchmarks.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Benchmarks\n",
"\n",
"This notebook contains the PGSO benchmarks conducted on the amazon ec2 instance using the following specifications:\n",
"\n",
"![Image](Benchmark_Images/benchmark_2.png)\n",
"\n",
"\n",
"## Benchmark for 8 cores spawning 1 process\n",
"![24_1_CPU](Benchmark_Images/1_CPU_Graph.png)\n",
"\n",
"## Benchmark for 8 cores spawning 2 process\n",
"![24_1_CPU](Benchmark_Images/2_CPU_Graph.png)\n",
"\n",
"## Benchmark for 8 cores spawning 4 process\n",
"![24_1_CPU](Benchmark_Images/4_CPU_Graph.png)\n",
"\n",
"## Benchmark for 8 cores spawning 6 process\n",
"![24_1_CPU](Benchmark_Images/6_CPU_Graph.png)\n",
"\n",
"## Benchmark for 8 cores spawning 8 process\n",
"![24_1_CPU](Benchmark_Images/8_CPU_Graph.png)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 814753c

Please sign in to comment.