1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
#!/usr/bin/python
#
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2015, ARM Limited and contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
# sys.path.insert(1, "./libs")
from perf_analysis import PerfAnalysis
from trace import Trace
import os
import re
import argparse
import json
# Configure logging
import logging
reload(logging)
logging.basicConfig(
format='%(asctime)-9s %(levelname)-8s: %(message)s',
level=logging.DEBUG,
# level=logging.INFO,
datefmt='%I:%M:%S')
# Regexp to match the format of a result folder
TEST_DIR_RE = re.compile(
r'([^:]*):([^:]*):([^:]*)'
)
parser = argparse.ArgumentParser(
description='EAS Performance and Trace Plotter')
parser.add_argument('--results', type=str,
default='./results_latest',
help='Folder containing experimental results')
parser.add_argument('--outdir', type=str,
default=None,
help='A single output folder we want to produce plots for')
parser.add_argument('--tmin', type=float,
default=None,
help='Minimum timestamp for all plots')
parser.add_argument('--tmax', type=float,
default=None,
help='Maximum timestamp for all plots')
parser.add_argument('--plots', type=str,
default='all',
help='List of plots to produce (all,')
args = None
def main():
global args
args = parser.parse_args()
# Setup plots to produce
if args.plots == 'all':
args.plots = 'tasks clusters cpus stune ediff edspace'
# For each rtapp and each run
if args.outdir is not None:
# Load platform descriptior
platform = None
plt_file = os.path.join(args.outdir, 'platform.json')
if os.path.isfile(plt_file):
with open(plt_file, 'r') as ifile:
platform = json.load(ifile)
logging.info('Platform description:')
logging.info(' %s', platform)
# Plot the specified results folder
return plotdir(args.outdir, platform)
for test_idx in sorted(os.listdir(args.results)):
match = TEST_DIR_RE.search(test_idx)
if match == None:
continue
wtype = match.group(1)
conf_idx = match.group(2)
wload_idx = match.group(3)
# Generate performance plots only for RTApp workloads
if wtype != 'rtapp':
continue
logging.debug('Processing [%s:%s:%s]...',
wtype, conf_idx, wload_idx)
# For each run of an rt-app workload
test_dir = os.path.join(args.results, test_idx)
# Load platform descriptior
platform = None
plt_file = os.path.join(test_dir, 'platform.json')
if os.path.isfile(plt_file):
with open(plt_file, 'r') as ifile:
platform = json.load(ifile)
logging.info('Platform description:')
logging.info(' %s', platform)
for run_idx in sorted(os.listdir(test_dir)):
run_dir = os.path.join(test_dir, run_idx)
try:
run_id = int(run_idx)
except ValueError:
continue
logging.info('Generate plots for [%s]...', run_dir)
plotdir(run_dir, platform)
def plotdir(run_dir, platform):
global args
tasks = None
pa = None
# Load RTApp performance data
try:
pa = PerfAnalysis(run_dir)
# Get the list of RTApp tasks
tasks = pa.tasks()
logging.info('Tasks: %s', tasks)
except ValueError:
pa = None
logging.info('No performance data found')
# Load Trace Analysis modules
trace = Trace(platform, run_dir)
# Define time ranges for all the temporal plots
trace.setXTimeRange(args.tmin, args.tmax)
# Tasks plots
if 'tasks' in args.plots:
trace.analysis.tasks.plotTasks(tasks)
if pa:
for task in tasks:
pa.plotPerf(task)
# Cluster and CPUs plots
if 'clusters' in args.plots:
trace.analysis.frequency.plotClusterFrequencies()
if 'cpus' in args.plots:
trace.analysis.cpus.plotCPU()
# SchedTune plots
if 'stune' in args.plots:
trace.analysis.eas.plotSchedTuneConf()
if 'ediff' in args.plots:
trace.analysis.eas.plotEDiffTime();
if 'edspace' in args.plots:
trace.analysis.eas.plotEDiffSpace();
if __name__ == "__main__":
main()
|