]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
parse-depmod: Allow to plot all at once
authorLucas De Marchi <lucas.demarchi@intel.com>
Fri, 16 Aug 2013 03:47:36 +0000 (00:47 -0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 25 Sep 2013 05:03:17 +0000 (02:03 -0300)
scripts/parse-depmod

index 3ff8a8bc715b06dddd7fcdac10152fc6f32f43c0..47539697d38222396753e614821426722d795507 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
 import sys
-
+import os.path
 
 def parse_table(f):
     curr = 0
@@ -36,23 +36,31 @@ def add_at(ax, t, loc=2):
     ax.add_artist(_at)
     return _at
 
-fig = plt.figure()
-
-with open(sys.argv[1]) as f:
-    for i in range(0, 3):
-        x, y = parse_table(f)
-        fit = np.polyfit(x, y, 1)
-        fit_fn = np.poly1d(fit)
-
-        ax = fig.add_subplot(2, 2, i, axisbg='#f6f6f6')
-        ax.plot(x, y, 'b', x, fit_fn(x), 'r')
-        ax.set_xlabel('bucket')
-        ax.set_ylabel('entries')
-        ax.axis('tight')
-        add_at(ax, 'mean=%.2f\nstddev=%.2f' % (np.mean(y), np.std(y)))
-        ax.grid(True)
-
-fig.suptitle('Hash distribution on buckets', weight='bold', size='large')
-fig.tight_layout()
-plt.subplots_adjust(top=0.9)
+
+figs = []
+for fn in sys.argv[1:]:
+    fig = plt.figure()
+    figs += [fig]
+
+    with open(fn) as f:
+        for i in range(0, 3):
+            x, y = parse_table(f)
+            fit = np.polyfit(x, y, 1)
+            fit_fn = np.poly1d(fit)
+
+            ax = fig.add_subplot(2, 2, i, axisbg='#f6f6f6')
+            ax.plot(x, y, 'b', x, fit_fn(x), 'r')
+            ax.set_xlabel('bucket')
+            ax.set_ylabel('entries')
+            ax.axis('tight')
+            add_at(ax, 'mean=%.2f\nstddev=%.2f' % (np.mean(y), np.std(y)))
+            ax.grid(True)
+
+    tit = os.path.splitext(os.path.basename(fn))[0]
+    fig.suptitle('Hash distribution on buckets: %s' % tit, weight='bold',
+                 size='large')
+    fig.tight_layout()
+    fig.subplots_adjust(top=0.9)
+
+
 plt.show()