Commit e749e09d authored by Doug Smythies's avatar Doug Smythies Committed by Rafael J. Wysocki
Browse files

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: default avatarDoug Smythies <dsmythies@telus.net>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent a7aebdeb
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -11,11 +11,11 @@ then this utility enables and collects trace data for a user specified interval
and generates performance plots.

Prerequisites:
    Python version 2.7.x
    Python version 2.7.x or higher
    gnuplot 5.0 or higher
    gnuplot-py 1.8
    gnuplot-py 1.8 or higher
    (Most of the distributions have these required packages. They may be called
     gnuplot-py, phython-gnuplot. )
     gnuplot-py, phython-gnuplot or phython3-gnuplot, gnuplot-nox, ... )

    HWP (Hardware P-States are disabled)
    Kernel config for Linux trace is enabled
@@ -181,7 +181,7 @@ def plot_pstate_cpu_with_sample():
        g_plot('set xlabel "Samples"')
        g_plot('set ylabel "P-State"')
        g_plot('set title "{} : cpu pstate vs. sample : {:%F %H:%M}"'.format(testname, datetime.now()))
        title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ')
        title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ')
        plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_SAMPLE, C_TO)
        g_plot('title_list = "{}"'.format(title_list))
        g_plot(plot_str)
@@ -198,7 +198,7 @@ def plot_pstate_cpu():
#    the following command is really cool, but doesn't work with the CPU masking option because it aborts on the first missing file.
#    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'
#
    title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).replace('\n', ' ')
    title_list = subprocess.check_output('ls cpu???.csv | sed -e \'s/.csv//\'',shell=True).decode('utf-8').replace('\n', ' ')
    plot_str = "plot for [i in title_list] i.'.csv' using {:d}:{:d} pt 7 ps 1 title i".format(C_ELAPSED, C_TO)
    g_plot('title_list = "{}"'.format(title_list))
    g_plot(plot_str)
@@ -212,7 +212,7 @@ def plot_load_cpu():
    g_plot('set ylabel "CPU load (percent)"')
    g_plot('set title "{} : cpu loads : {:%F %H:%M}"'.format(testname, datetime.now()))

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

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

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

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

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

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