blob: 32ce8e3b8582537f5d0ba444fdee23be261e6508 [file] [log] [blame]
Brendan Jackmane81fdcb2017-01-04 17:10:29 +00001# Copyright 2015-2017 ARM Limited
Javi Merino034e7cc2015-04-22 18:39:21 +01002#
Javi Merinoaace7c02015-08-10 14:10:47 +01003# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
Kapileshwar Singh77d16772015-01-21 18:07:15 +000016
17import unittest
18import matplotlib
19import pandas as pd
20import utils_tests
Javi Merino435457c2015-08-10 15:59:10 +010021import trappy
Kapileshwar Singh77d16772015-01-21 18:07:15 +000022import shutil
23
24from test_thermal import BaseTestThermal
25
26
27class TestPlotterDupVals(BaseTestThermal):
28
29 """Test Duplicate Entries in plotter"""
30
31 def __init__(self, *args, **kwargs):
32 super(TestPlotterDupVals, self).__init__(*args, **kwargs)
33
34 def test_plotter_duplicates(self):
35 """Test that plotter handles duplicates fine"""
36 with open("trace.txt", "w") as fout:
37 fout.write("""version = 6
38cpus=6
Javi Merino0302ef72015-03-27 19:27:11 +000039 rcuos/2-22 [001] 0000.018510: sched_load_avg_sg: cpus=00000001 load=0 utilization=0
40 rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000002 load=1 utilization=1
41 rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000004 load=2 utilization=2
42 rcuos/2-22 [001] 6550.018612: sched_load_avg_sg: cpus=00000001 load=2 utilization=3
43 rcuos/2-22 [001] 6550.018624: sched_load_avg_sg: cpus=00000002 load=1 utilization=4
44 rcuos/2-22 [001] 6550.018625: sched_load_avg_sg: cpus=00000002 load=2 utilization=5
45 rcuos/2-22 [001] 6550.018626: sched_load_avg_sg: cpus=00000002 load=3 utilization=6
46 rcuos/2-22 [001] 6550.018627: sched_load_avg_sg: cpus=00000002 load=1 utilization=7
47 rcuos/2-22 [001] 6550.018628: sched_load_avg_sg: cpus=00000004 load=2 utilization=8\n""")
Kapileshwar Singh77d16772015-01-21 18:07:15 +000048 fout.close()
Javi Merinoc26a3232015-12-11 18:00:30 +000049 trace1 = trappy.FTrace(name="first")
Javi Merino435457c2015-08-10 15:59:10 +010050 l = trappy.LinePlot(
Javi Merinoc26a3232015-12-11 18:00:30 +000051 trace1,
Javi Merino435457c2015-08-10 15:59:10 +010052 trappy.sched.SchedLoadAvgSchedGroup,
Kapileshwar Singh77d16772015-01-21 18:07:15 +000053 column=['utilization'],
54 filters={
55 "load": [
56 1,
57 2]},
58 pivot="cpus",
59 marker='o',
60 linestyle='none',
61 per_line=3)
Kapileshwar Singha2040442015-02-23 12:19:18 +000062 l.view(test=True)
Kapileshwar Singh77d16772015-01-21 18:07:15 +000063
64 def test_plotter_triplicates(self):
65
66 """Test that plotter handles triplicates fine"""
67
68 with open("trace.txt", "w") as fout:
69 fout.write("""version = 6
70cpus=6
Javi Merino0302ef72015-03-27 19:27:11 +000071 rcuos/2-22 [001] 0000.018510: sched_load_avg_sg: cpus=00000001 load=0 utilization=0
72 rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000002 load=1 utilization=1
73 rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000004 load=2 utilization=2
74 rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000004 load=2 utilization=2
75 rcuos/2-22 [001] 6550.018612: sched_load_avg_sg: cpus=00000001 load=2 utilization=3
76 rcuos/2-22 [001] 6550.018624: sched_load_avg_sg: cpus=00000002 load=1 utilization=4
77 rcuos/2-22 [001] 6550.018625: sched_load_avg_sg: cpus=00000002 load=2 utilization=5
78 rcuos/2-22 [001] 6550.018626: sched_load_avg_sg: cpus=00000002 load=3 utilization=6
79 rcuos/2-22 [001] 6550.018627: sched_load_avg_sg: cpus=00000002 load=1 utilization=7
80 rcuos/2-22 [001] 6550.018628: sched_load_avg_sg: cpus=00000004 load=2 utilization=8\n""")
Kapileshwar Singh77d16772015-01-21 18:07:15 +000081 fout.close()
82
Javi Merinoc26a3232015-12-11 18:00:30 +000083 trace1 = trappy.FTrace(name="first")
Javi Merino435457c2015-08-10 15:59:10 +010084 l = trappy.LinePlot(
Javi Merinoc26a3232015-12-11 18:00:30 +000085 trace1,
Javi Merino435457c2015-08-10 15:59:10 +010086 trappy.sched.SchedLoadAvgSchedGroup,
Kapileshwar Singh77d16772015-01-21 18:07:15 +000087 column=['utilization'],
88 filters={
89 "load": [
90 1,
91 2]},
92 pivot="cpus",
93 marker='o',
94 linestyle='none',
95 per_line=3)
Kapileshwar Singha2040442015-02-23 12:19:18 +000096 l.view(test=True)