David 10 yıl önce
ebeveyn
işleme
24d552b306
1 değiştirilmiş dosya ile 35 ekleme ve 52 silme
  1. 35 52
      scripts/plotter.py

+ 35 - 52
scripts/plotter.py

@@ -1,71 +1,54 @@
 #!/usr/bin/env python
-# a bar plot with errorbars
 import numpy as np
 import matplotlib.pyplot as plt
 
-cMeans=(0.00163314,0.0030878,0.00756769,0.0714377,1.13022)
-cStd=(0.000345353,0.000641013,0.00106808,0.00224826,0.0172249)
-asmMeans1=(0.00125512,0.00198333,0.00841489,0.0665831,1.15417)
-asmStd1=(0.000259477,0.000390865,0.000991933,0.00100535,0.0327828)
-asmMeans2=(0.00125345,0.0014143,0.00290749,0.0199608,0.389258)
-asmStd2=(0.000268301,0.000549018,0.000486762,0.00257161,0.0221019)
+process_data = [
+                {'cargaTick': 3, 'primerTick': 4, 'ticksBlock': 9, 'ticksCpu': 11, 'ultimoTick': 24},
+                {'cargaTick': 5, 'primerTick': 25, 'ticksBlock': 11, 'ticksCpu': 5, 'ultimoTick': 41},
+                {'cargaTick': 5, 'primerTick': 42, 'ticksBlock': 12, 'ticksCpu': 5, 'ultimoTick': 59}
+               ]
 
+fig, ax = plt.subplots(figsize=(10,5))
 
-#merge
-cMeans= (0.00124538,0.00128132,0.00121279,0.0030127,0.0205496)
-cStd= (0.000209686,0.000236924,0.000278824,0.000512202,0.0016461)
-asmMeans1= (0.0012121,0.00121418,0.00125287,0.00254286,0.0164427)
-asmStd1= (0.000191275,0.000190012,0.000139698,0.00044915,0.00159364)
-asmMeans2= (0.00119275,0.00130064,0.00114465,0.00240577,0.0149295)
-asmStd2= (0.000220732,0.000188047,0.000178148,0.000391202,0.00173487)
+index = list(range(len(process_data)))
+bar_width = 0.25
 
-tams = [ 1, 4, 16, 64, 1024 ]
+opacity = 0.9
+error_config = {'ecolor': '0.3'}
 
-cMeans		= tuple( i / tams[cMeans.index(i)] for i in cMeans)
-asmMeans1	= tuple( i / tams[asmMeans1.index(i)] for i in asmMeans1)
-asmMeans2	= tuple( i / tams[asmMeans2.index(i)] for i in asmMeans2)
-cStd		= tuple( i / tams[cStd.index(i)] for i in cStd)
-asmStd1		= tuple( i / tams[asmStd1.index(i)] for i in asmStd1)
-asmStd2		= tuple( i / tams[asmStd2.index(i)] for i in asmStd2)
+def latency(p):
+    return p["primerTick"]-p["cargaTick"]
 
+def ready(p):
+    return (p["ultimoTick"]-p["primerTick"])-(p["ticksBlock"]+p["ticksCpu"])+(p["primerTick"]-p["cargaTick"])
 
-n_groups = len(cMeans)
+def cpu(p):
+    return p["ticksCpu"]
+def cpu_io(p):
+    return p["ticksBlock"]+p["ticksCpu"]
 
-fig, ax = plt.subplots()
 
-index = np.arange(n_groups)
-bar_width = 0.25
+def plot_data(ind, data, color, label):
+    plt.bar([i + bar_width*ind for i in index],
+        data,
+        bar_width,
+        alpha=opacity,
+        color=color,
+        error_kw=error_config,
+        label=(label))
 
-opacity = 0.6
-error_config = {'ecolor': '0.3'}
+plot_data(0,[latency(p) for p in process_data], 'r', 'Latency')
+plot_data(1,[ready(p) for p in process_data],   'g', 'Ready')
+plot_data(2,[cpu(p) for p in process_data],     'b', 'CPU')
+plot_data(3,[cpu_io(p) for p in process_data],  '#fafafa', 'CPU+IO')
 
-rects1 = plt.bar(index, cMeans, bar_width,
-                 alpha=opacity,
-                 color='b',
-                 yerr=cStd,
-                 error_kw=error_config,
-                 label='C')
+ax.set_ylabel('Time')
+ax.set_title('title')
+ax.set_xticks([ i + 1.5 * bar_width for i in index])
+ax.set_xticklabels(["Process %d" % i for i in xrange(len(process_data))])
 
-rects2 = plt.bar(index + bar_width, asmMeans1, bar_width,
-                 alpha=opacity,
-                 color='r',
-                 yerr=asmStd1,
-                 error_kw=error_config,
-                 label='ASM1')
-
-rects3 = plt.bar(index + 2*bar_width, asmMeans2, bar_width,
-                 alpha=opacity,
-                 color='g',
-                 yerr=asmStd2,
-                 error_kw=error_config,
-                 label='ASM2')
-
-plt.xlabel('Tamano')
-plt.ylabel('Tiempo')
-plt.title('Tiempo de ejecucion por pixel')
-plt.xticks(index + bar_width, (16,32,64,256,1024))
 plt.legend()
 
 plt.tight_layout()
+plt.grid()
 plt.show()
-