1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | # |
---|
4 | # Copyright (c) 2016 embedded brains GmbH. All rights reserved. |
---|
5 | # |
---|
6 | # The license and distribution terms for this file may be |
---|
7 | # found in the file LICENSE in this distribution or at |
---|
8 | # http://www.rtems.org/license/LICENSE. |
---|
9 | # |
---|
10 | |
---|
11 | import re |
---|
12 | import libxml2 |
---|
13 | from libxml2 import xmlNode |
---|
14 | import matplotlib.pyplot as plt |
---|
15 | data = open('smplock01.scn').read() |
---|
16 | data = re.sub(r'\*\*\*.*\*\*\*', '', data) |
---|
17 | doc = libxml2.parseDoc(data) |
---|
18 | ctx = doc.xpathNewContext() |
---|
19 | |
---|
20 | plt.title('SMP Lock Performance') |
---|
21 | plt.xlabel('Active Workers') |
---|
22 | plt.ylabel('Operation Count') |
---|
23 | |
---|
24 | y = map(xmlNode.getContent, ctx.xpathEval('/SMPLock01/GlobalTicketLockWithLocalCounter/SumOfLocalCounter')) |
---|
25 | x = range(1, len(y) + 1) |
---|
26 | plt.plot(x, y, label = 'Ticket Lock', marker = 'o') |
---|
27 | |
---|
28 | y = map(xmlNode.getContent, ctx.xpathEval('/SMPLock01/GlobalMCSLockWithLocalCounter/SumOfLocalCounter')) |
---|
29 | plt.plot(x, y, label = 'MCS Lock', marker = 'o') |
---|
30 | |
---|
31 | y = map(xmlNode.getContent, ctx.xpathEval('/SMPLock01/GlobalTASLockWithLocalCounter/SumOfLocalCounter')) |
---|
32 | plt.plot(x, y, label = 'TAS Lock', marker = 'o') |
---|
33 | |
---|
34 | y = map(xmlNode.getContent, ctx.xpathEval('/SMPLock01/GlobalTTASLockWithLocalCounter/SumOfLocalCounter')) |
---|
35 | plt.plot(x, y, label = 'TTAS Lock', marker = 'o') |
---|
36 | |
---|
37 | plt.legend(loc = 'best') |
---|
38 | plt.show() |
---|