source: rtems/testsuites/tmtests/tmcontext01/plot.py @ b2356837

4.115
Last change on this file since b2356837 was b2356837, checked in by Sebastian Huber <sebastian.huber@…>, on 09/05/14 at 06:24:52

tmtests/tmcontext01: Plot a legend

  • Property mode set to 100644
File size: 1.3 KB
Line 
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
9import libxml2
10from libxml2 import xmlNode
11import matplotlib.pyplot as plt
12doc = libxml2.parseFile("tmcontext01.scn")
13ctx = doc.xpathNewContext()
14
15colors = ['k', 'r', 'b', 'g', 'y', 'm']
16
17def 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
25plt.title("context switch timing test")
26plt.xlabel('function nest level')
27plt.ylabel('context switch time [ns]')
28
29c = 0
30for 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
37load = 1
38while 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
50plt.legend()
51plt.show()
Note: See TracBrowser for help on using the repository browser.