Skip to content

Commit e749e09

Browse files
Doug Smythiesrafaeljw
authored andcommitted
tools/power/x86/intel_pstate_tracer: changes for python 3 compatibility
Some syntax needs to be more rigorous for python 3. Backwards compatibility tested with python 2.7 Signed-off-by: Doug Smythies <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent a7aebde commit e749e09

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
and generates performance plots.
1212
1313
Prerequisites:
14-
Python version 2.7.x
14+
Python version 2.7.x or higher
1515
gnuplot 5.0 or higher
16-
gnuplot-py 1.8
16+
gnuplot-py 1.8 or higher
1717
(Most of the distributions have these required packages. They may be called
18-
gnuplot-py, phython-gnuplot. )
18+
gnuplot-py, phython-gnuplot or phython3-gnuplot, gnuplot-nox, ... )
1919
2020
HWP (Hardware P-States are disabled)
2121
Kernel config for Linux trace is enabled
@@ -181,7 +181,7 @@ def plot_pstate_cpu_with_sample():
181181
g_plot('set xlabel "Samples"')
182182
g_plot('set ylabel "P-State"')
183183
g_plot('set title "{} : cpu pstate vs. sample : {:%F %H:%M}"'.format(testname, datetime.now()))
184-
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ')
184+
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ')
185185
plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_SAMPLE, C_TO)
186186
g_plot('title_list = "{}"'.format(title_list))
187187
g_plot(plot_str)
@@ -198,7 +198,7 @@ def plot_pstate_cpu():
198198
# the following command is really cool, but doesn't work with the CPU masking option because it aborts on the first missing file.
199199
# plot_str = 'plot for [i=0:*] file=sprintf("cpu%03d.csv",i) title_s=sprintf("cpu%03d",i) file using 16:7 pt 7 ps 1 title title_s'
200200
#
201-
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ')
201+
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ')
202202
plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_TO)
203203
g_plot('title_list = "{}"'.format(title_list))
204204
g_plot(plot_str)
@@ -212,7 +212,7 @@ def plot_load_cpu():
212212
g_plot('set ylabel "CPU load (percent)"')
213213
g_plot('set title "{} : cpu loads : {:%F %H:%M}"'.format(testname, datetime.now()))
214214

215-
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ')
215+
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ')
216216
plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_LOAD)
217217
g_plot('title_list = "{}"'.format(title_list))
218218
g_plot(plot_str)
@@ -226,7 +226,7 @@ def plot_frequency_cpu():
226226
g_plot('set ylabel "CPU Frequency (GHz)"')
227227
g_plot('set title "{} : cpu frequencies : {:%F %H:%M}"'.format(testname, datetime.now()))
228228

229-
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ')
229+
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ')
230230
plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_FREQ)
231231
g_plot('title_list = "{}"'.format(title_list))
232232
g_plot(plot_str)
@@ -241,7 +241,7 @@ def plot_duration_cpu():
241241
g_plot('set ylabel "Timer Duration (MilliSeconds)"')
242242
g_plot('set title "{} : cpu durations : {:%F %H:%M}"'.format(testname, datetime.now()))
243243

244-
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ')
244+
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ')
245245
plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_DURATION)
246246
g_plot('title_list = "{}"'.format(title_list))
247247
g_plot(plot_str)
@@ -255,7 +255,7 @@ def plot_scaled_cpu():
255255
g_plot('set ylabel "Scaled Busy (Unitless)"')
256256
g_plot('set title "{} : cpu scaled busy : {:%F %H:%M}"'.format(testname, datetime.now()))
257257

258-
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ')
258+
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ')
259259
plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_SCALED)
260260
g_plot('title_list = "{}"'.format(title_list))
261261
g_plot(plot_str)
@@ -269,7 +269,7 @@ def plot_boost_cpu():
269269
g_plot('set ylabel "CPU IO Boost (percent)"')
270270
g_plot('set title "{} : cpu io boost : {:%F %H:%M}"'.format(testname, datetime.now()))
271271

272-
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ')
272+
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ')
273273
plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_BOOST)
274274
g_plot('title_list = "{}"'.format(title_list))
275275
g_plot(plot_str)
@@ -283,7 +283,7 @@ def plot_ghz_cpu():
283283
g_plot('set ylabel "TSC Frequency (GHz)"')
284284
g_plot('set title "{} : cpu TSC Frequencies (Sanity check calculation) : {:%F %H:%M}"'.format(testname, datetime.now()))
285285

286-
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ')
286+
title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ')
287287
plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_GHZ)
288288
g_plot('title_list = "{}"'.format(title_list))
289289
g_plot(plot_str)

0 commit comments

Comments
 (0)