summaryrefslogtreecommitdiffstats
path: root/testsuites/smptests/smplock01/smplock01fair.py
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-11-22 12:51:12 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-11-23 12:52:05 +0100
commita6283671f31498773d0842b43884048c8d2d61fd (patch)
treed7b67b51c162a09f084c48f4fe296b416581c2b2 /testsuites/smptests/smplock01/smplock01fair.py
parentlibtests/cpuuse: Check status only (diff)
downloadrtems-a6283671f31498773d0842b43884048c8d2d61fd.tar.bz2
smptests/smplock01: Test TAS and TTAS locks
Cache align locks in the context.
Diffstat (limited to 'testsuites/smptests/smplock01/smplock01fair.py')
-rwxr-xr-xtestsuites/smptests/smplock01/smplock01fair.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/testsuites/smptests/smplock01/smplock01fair.py b/testsuites/smptests/smplock01/smplock01fair.py
new file mode 100755
index 0000000000..23f85db23d
--- /dev/null
+++ b/testsuites/smptests/smplock01/smplock01fair.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+
+#
+# Copyright (c) 2016 embedded brains GmbH. All rights reserved.
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.rtems.org/license/LICENSE.
+#
+
+import re
+import libxml2
+import math
+import statistics
+from libxml2 import xmlNode
+import matplotlib.pyplot as plt
+data = open('smplock01.scn').read()
+data = re.sub(r'\*\*\*.*\*\*\*', '', data)
+doc = libxml2.parseDoc(data)
+ctx = doc.xpathNewContext()
+
+plt.title('SMP Lock Fairness')
+plt.xlabel('Active Workers')
+plt.ylabel('Normed Coefficient of Variation')
+
+i = 1
+ticket = []
+mcs = []
+tas = []
+ttas = []
+
+def m(n):
+ return int(xmlNode.getContent(n))
+
+def normedCoefficientOfVariation(name, i):
+ y = map(m, ctx.xpathEval('/SMPLock01/' + name + '[@activeWorker=' + str(i) + ']/LocalCounter'))
+ if len(y) == 0:
+ raise
+ return (statistics.stdev(y) / statistics.mean(y)) / math.sqrt(len(y) - 1)
+
+try:
+ while True:
+ i = i + 1
+ ticket.append(normedCoefficientOfVariation('GlobalTicketLockWithLocalCounter', i))
+ mcs.append(normedCoefficientOfVariation('GlobalMCSLockWithLocalCounter', i))
+ tas.append(normedCoefficientOfVariation('GlobalTASLockWithLocalCounter', i))
+ ttas.append(normedCoefficientOfVariation('GlobalTTASLockWithLocalCounter', i))
+except:
+ pass
+
+x = range(1, len(ticket) + 1)
+plt.yscale('log')
+plt.plot(x, ticket, label = 'Ticket Lock', marker = 'o')
+plt.plot(x, mcs, label = 'MCS Lock', marker = 'o')
+plt.plot(x, tas, label = 'TAS Lock', marker = 'o')
+plt.plot(x, ttas, label = 'TTAS Lock', marker = 'o')
+plt.legend(loc = 'best')
+plt.show()