Brendan Jackman | e81fdcb | 2017-01-04 17:10:29 +0000 | [diff] [blame] | 1 | # Copyright 2015-2017 ARM Limited |
Javi Merino | 034e7cc | 2015-04-22 18:39:21 +0100 | [diff] [blame] | 2 | # |
Javi Merino | aace7c0 | 2015-08-10 14:10:47 +0100 | [diff] [blame] | 3 | # 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 Singh | 77d1677 | 2015-01-21 18:07:15 +0000 | [diff] [blame] | 16 | |
| 17 | import unittest |
| 18 | import matplotlib |
| 19 | import pandas as pd |
| 20 | import utils_tests |
Javi Merino | 435457c | 2015-08-10 15:59:10 +0100 | [diff] [blame] | 21 | import trappy |
Kapileshwar Singh | 77d1677 | 2015-01-21 18:07:15 +0000 | [diff] [blame] | 22 | import shutil |
| 23 | |
| 24 | from test_thermal import BaseTestThermal |
| 25 | |
| 26 | |
| 27 | class 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 |
| 38 | cpus=6 |
Javi Merino | 0302ef7 | 2015-03-27 19:27:11 +0000 | [diff] [blame] | 39 | 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 Singh | 77d1677 | 2015-01-21 18:07:15 +0000 | [diff] [blame] | 48 | fout.close() |
Javi Merino | c26a323 | 2015-12-11 18:00:30 +0000 | [diff] [blame] | 49 | trace1 = trappy.FTrace(name="first") |
Javi Merino | 435457c | 2015-08-10 15:59:10 +0100 | [diff] [blame] | 50 | l = trappy.LinePlot( |
Javi Merino | c26a323 | 2015-12-11 18:00:30 +0000 | [diff] [blame] | 51 | trace1, |
Javi Merino | 435457c | 2015-08-10 15:59:10 +0100 | [diff] [blame] | 52 | trappy.sched.SchedLoadAvgSchedGroup, |
Kapileshwar Singh | 77d1677 | 2015-01-21 18:07:15 +0000 | [diff] [blame] | 53 | column=['utilization'], |
| 54 | filters={ |
| 55 | "load": [ |
| 56 | 1, |
| 57 | 2]}, |
| 58 | pivot="cpus", |
| 59 | marker='o', |
| 60 | linestyle='none', |
| 61 | per_line=3) |
Kapileshwar Singh | a204044 | 2015-02-23 12:19:18 +0000 | [diff] [blame] | 62 | l.view(test=True) |
Kapileshwar Singh | 77d1677 | 2015-01-21 18:07:15 +0000 | [diff] [blame] | 63 | |
| 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 |
| 70 | cpus=6 |
Javi Merino | 0302ef7 | 2015-03-27 19:27:11 +0000 | [diff] [blame] | 71 | 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 Singh | 77d1677 | 2015-01-21 18:07:15 +0000 | [diff] [blame] | 81 | fout.close() |
| 82 | |
Javi Merino | c26a323 | 2015-12-11 18:00:30 +0000 | [diff] [blame] | 83 | trace1 = trappy.FTrace(name="first") |
Javi Merino | 435457c | 2015-08-10 15:59:10 +0100 | [diff] [blame] | 84 | l = trappy.LinePlot( |
Javi Merino | c26a323 | 2015-12-11 18:00:30 +0000 | [diff] [blame] | 85 | trace1, |
Javi Merino | 435457c | 2015-08-10 15:59:10 +0100 | [diff] [blame] | 86 | trappy.sched.SchedLoadAvgSchedGroup, |
Kapileshwar Singh | 77d1677 | 2015-01-21 18:07:15 +0000 | [diff] [blame] | 87 | column=['utilization'], |
| 88 | filters={ |
| 89 | "load": [ |
| 90 | 1, |
| 91 | 2]}, |
| 92 | pivot="cpus", |
| 93 | marker='o', |
| 94 | linestyle='none', |
| 95 | per_line=3) |
Kapileshwar Singh | a204044 | 2015-02-23 12:19:18 +0000 | [diff] [blame] | 96 | l.view(test=True) |