source: rtems/testsuites/smptests/smplock01/smplock01fair.py @ a6283671

5
Last change on this file since a6283671 was a6283671, checked in by Sebastian Huber <sebastian.huber@…>, on 11/22/16 at 11:51:12

smptests/smplock01: Test TAS and TTAS locks

Cache align locks in the context.

  • Property mode set to 100755
File size: 1.6 KB
Line 
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
11import re
12import libxml2
13import math
14import statistics
15from libxml2 import xmlNode
16import matplotlib.pyplot as plt
17data = open('smplock01.scn').read()
18data = re.sub(r'\*\*\*.*\*\*\*', '', data)
19doc = libxml2.parseDoc(data)
20ctx = doc.xpathNewContext()
21
22plt.title('SMP Lock Fairness')
23plt.xlabel('Active Workers')
24plt.ylabel('Normed Coefficient of Variation')
25
26i = 1
27ticket = []
28mcs = []
29tas = []
30ttas = []
31
32def m(n):
33        return int(xmlNode.getContent(n))
34
35def normedCoefficientOfVariation(name, i):
36        y = map(m, ctx.xpathEval('/SMPLock01/' + name + '[@activeWorker=' + str(i) + ']/LocalCounter'))
37        if len(y) == 0:
38                raise
39        return (statistics.stdev(y) / statistics.mean(y)) / math.sqrt(len(y) - 1)
40
41try:
42        while True:
43                i = i + 1
44                ticket.append(normedCoefficientOfVariation('GlobalTicketLockWithLocalCounter', i))
45                mcs.append(normedCoefficientOfVariation('GlobalMCSLockWithLocalCounter', i))
46                tas.append(normedCoefficientOfVariation('GlobalTASLockWithLocalCounter', i))
47                ttas.append(normedCoefficientOfVariation('GlobalTTASLockWithLocalCounter', i))
48except:
49        pass
50
51x = range(1, len(ticket) + 1)
52plt.yscale('log')
53plt.plot(x, ticket, label = 'Ticket Lock', marker = 'o')
54plt.plot(x, mcs, label = 'MCS Lock', marker = 'o')
55plt.plot(x, tas, label = 'TAS Lock', marker = 'o')
56plt.plot(x, ttas, label = 'TTAS Lock', marker = 'o')
57plt.legend(loc = 'best')
58plt.show()
Note: See TracBrowser for help on using the repository browser.