Sfoglia il codice sorgente

SCRIPTS: Added plot script in Python

The plot of the graphs done with gnuplot was too customary and not
extendible.
I took adavantage of numpy and matplotlib and rewrote the whole thing in
Python
Andrea Gus 8 anni fa
parent
commit
4da66857c4
1 ha cambiato i file con 36 aggiunte e 0 eliminazioni
  1. 36 0
      utils/plot.py

+ 36 - 0
utils/plot.py

@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+import numpy as np
+import matplotlib.mlab as mlab
+import matplotlib.pyplot as plt
+import matplotlib.patches as mpatches
+
+# Import data from file
+data_cpu = np.genfromtxt('results/cpu/times.dat', dtype=None, delimiter=' ', names=['name', 'time'])
+data_gpu = np.genfromtxt('results/gpu/times.dat', dtype=None, delimiter=' ', names=['name', 'time'])
+
+# Generate an array as placeholder for the x axis (we need to pass from a list to an array to take advantage of range)
+x = range(0, 17)
+# Strip away the "opencl/" prefix from all the name
+stripped_names = []
+for elem in data_cpu['name']:
+    elem = elem.replace("opencl/", "")
+    elem = elem.replace("/ocl", "")
+    elem = elem.replace("/OpenCL", "")
+    stripped_names.append(elem)
+
+# Create the bar plot
+plt.bar(x, data_cpu['time'], width=0.5, color='b', align='edge')
+plt.bar(x, data_gpu['time'], width=-0.5, color='r', align='center')
+plt.xticks(x, stripped_names)
+plt.title('Execution time of the various benchmarks expressed in seconds')
+plt.xlabel('Benchmark')
+plt.ylabel('seconds')
+
+# Add some patches as legend of the colors used for the various benchmarks
+red_patch = mpatches.Patch(color='blue', label='Execution time for cpu')
+
+blue_patch = mpatches.Patch(color='red', label='Execution time for gpu')
+
+plt.legend(handles=[blue_patch, red_patch])
+
+plt.show()