1 | # |
---|
2 | # Copyright (c) 2014 embedded brains GmbH. All rights reserved. |
---|
3 | # |
---|
4 | # The license and distribution terms for this file may be |
---|
5 | # found in the file LICENSE in this distribution or at |
---|
6 | # http://www.rtems.org/license/LICENSE. |
---|
7 | # |
---|
8 | |
---|
9 | import libxml2 |
---|
10 | from libxml2 import xmlNode |
---|
11 | import matplotlib.pyplot as plt |
---|
12 | doc = libxml2.parseFile("tmcontext01.scn") |
---|
13 | ctx = doc.xpathNewContext() |
---|
14 | |
---|
15 | colors = ['k', 'r', 'b', 'g', 'y', 'm'] |
---|
16 | |
---|
17 | def plot(y, color, label, first): |
---|
18 | n=len(y) |
---|
19 | x=range(0, n) |
---|
20 | if first: |
---|
21 | plt.plot(x, y, color=color, label=label) |
---|
22 | else: |
---|
23 | plt.plot(x, y, color=color) |
---|
24 | |
---|
25 | plt.title("context switch timing test") |
---|
26 | plt.xlabel('function nest level') |
---|
27 | plt.ylabel('context switch time [ns]') |
---|
28 | |
---|
29 | c = 0 |
---|
30 | for e in ["normal", "dirty"]: |
---|
31 | first = True |
---|
32 | for i in ["Min", "Q1", "Q2", "Q3", "Max"]: |
---|
33 | y=map(xmlNode.getContent, ctx.xpathEval("/Test/ContextSwitchTest[@environment='" + e + "' and not(@load)]/Sample/" + i)) |
---|
34 | plot(y, colors[c], e, first) |
---|
35 | first = False |
---|
36 | c = c + 1 |
---|
37 | load = 1 |
---|
38 | while load > 0: |
---|
39 | first = True |
---|
40 | for i in ["Min", "Q1", "Q2", "Q3", "Max"]: |
---|
41 | y=map(xmlNode.getContent, ctx.xpathEval("/Test/ContextSwitchTest[@environment='dirty' and @load='" + str(load) + "']/Sample/" + i)) |
---|
42 | if len(y) > 0: |
---|
43 | plot(y, colors[c], "load " + str(load), first) |
---|
44 | first = False |
---|
45 | else: |
---|
46 | load = 0 |
---|
47 | if load > 0: |
---|
48 | load = load + 1 |
---|
49 | c = c + 1 |
---|
50 | plt.legend() |
---|
51 | plt.show() |
---|