Kapileshwar Singh | 77d1677 | 2015-01-21 18:07:15 +0000 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | import unittest |
| 4 | import matplotlib |
| 5 | import pandas as pd |
| 6 | import utils_tests |
| 7 | import cr2 |
| 8 | import shutil |
| 9 | |
| 10 | from test_thermal import BaseTestThermal |
| 11 | |
| 12 | |
| 13 | class TestPlotterDupVals(BaseTestThermal): |
| 14 | |
| 15 | """Test Duplicate Entries in plotter""" |
| 16 | |
| 17 | def __init__(self, *args, **kwargs): |
| 18 | super(TestPlotterDupVals, self).__init__(*args, **kwargs) |
| 19 | |
| 20 | def test_plotter_duplicates(self): |
| 21 | """Test that plotter handles duplicates fine""" |
| 22 | with open("trace.txt", "w") as fout: |
| 23 | fout.write("""version = 6 |
| 24 | cpus=6 |
| 25 | rcuos/2-22 [001] 0000.018510: sched_load_avg_sg: cpus=00000001 load=0 utilization=0 |
| 26 | rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000002 load=1 utilization=1 |
| 27 | rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000004 load=2 utilization=2 |
| 28 | rcuos/2-22 [001] 6550.018612: sched_load_avg_sg: cpus=00000001 load=2 utilization=3 |
| 29 | rcuos/2-22 [001] 6550.018624: sched_load_avg_sg: cpus=00000002 load=1 utilization=4 |
| 30 | rcuos/2-22 [001] 6550.018625: sched_load_avg_sg: cpus=00000002 load=2 utilization=5 |
| 31 | rcuos/2-22 [001] 6550.018626: sched_load_avg_sg: cpus=00000002 load=3 utilization=6 |
| 32 | rcuos/2-22 [001] 6550.018627: sched_load_avg_sg: cpus=00000002 load=1 utilization=7 |
| 33 | rcuos/2-22 [001] 6550.018628: sched_load_avg_sg: cpus=00000004 load=2 utilization=8\n""") |
| 34 | fout.close() |
| 35 | run1 = cr2.Run(name="first") |
| 36 | l = cr2.LinePlot( |
| 37 | run1, |
| 38 | cr2.sched.SchedLoadAvgSchedGroup, |
| 39 | column=['utilization'], |
| 40 | filters={ |
| 41 | "load": [ |
| 42 | 1, |
| 43 | 2]}, |
| 44 | pivot="cpus", |
| 45 | marker='o', |
| 46 | linestyle='none', |
| 47 | per_line=3) |
| 48 | l.view() |
| 49 | matplotlib.pyplot.close('all') |
| 50 | |
| 51 | def test_plotter_triplicates(self): |
| 52 | |
| 53 | """Test that plotter handles triplicates fine""" |
| 54 | |
| 55 | with open("trace.txt", "w") as fout: |
| 56 | fout.write("""version = 6 |
| 57 | cpus=6 |
| 58 | rcuos/2-22 [001] 0000.018510: sched_load_avg_sg: cpus=00000001 load=0 utilization=0 |
| 59 | rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000002 load=1 utilization=1 |
| 60 | rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000004 load=2 utilization=2 |
| 61 | rcuos/2-22 [001] 6550.018611: sched_load_avg_sg: cpus=00000004 load=2 utilization=2 |
| 62 | rcuos/2-22 [001] 6550.018612: sched_load_avg_sg: cpus=00000001 load=2 utilization=3 |
| 63 | rcuos/2-22 [001] 6550.018624: sched_load_avg_sg: cpus=00000002 load=1 utilization=4 |
| 64 | rcuos/2-22 [001] 6550.018625: sched_load_avg_sg: cpus=00000002 load=2 utilization=5 |
| 65 | rcuos/2-22 [001] 6550.018626: sched_load_avg_sg: cpus=00000002 load=3 utilization=6 |
| 66 | rcuos/2-22 [001] 6550.018627: sched_load_avg_sg: cpus=00000002 load=1 utilization=7 |
| 67 | rcuos/2-22 [001] 6550.018628: sched_load_avg_sg: cpus=00000004 load=2 utilization=8\n""") |
| 68 | fout.close() |
| 69 | |
| 70 | run1 = cr2.Run(name="first") |
| 71 | l = cr2.LinePlot( |
| 72 | run1, |
| 73 | cr2.sched.SchedLoadAvgSchedGroup, |
| 74 | column=['utilization'], |
| 75 | filters={ |
| 76 | "load": [ |
| 77 | 1, |
| 78 | 2]}, |
| 79 | pivot="cpus", |
| 80 | marker='o', |
| 81 | linestyle='none', |
| 82 | per_line=3) |
| 83 | l.view() |
| 84 | matplotlib.pyplot.close('all') |