Fix tidiness errors for Python3 compatibility across whole repo

This commit is contained in:
marmeladema 2019-12-10 23:56:12 +00:00
parent 9d04f231f4
commit 7b5fabe855
10 changed files with 51 additions and 41 deletions

View file

@ -4,6 +4,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import print_function
import sys
import os
from os import path
@ -12,6 +14,7 @@ import datetime
import argparse
import platform
import subprocess
import six
TOP_DIR = path.join("..", "..")
GUARD_TIME = 10
@ -133,7 +136,7 @@ def execute(base_dir, build_target, renderer, page, profile, trial, layout_threa
log_dir = path.join(base_dir, "logs_l" + str(layout_thread_count),
"trial_" + str(trial))
if os.path.exists(log_dir):
print "Log directory already exists: " + log_dir
print("Log directory already exists: " + log_dir)
sys.exit(1)
os.makedirs(log_dir)
@ -142,16 +145,16 @@ def execute(base_dir, build_target, renderer, page, profile, trial, layout_threa
# Execute
start_energy_reader()
print 'sleep ' + str(GUARD_TIME)
print('sleep ' + str(GUARD_TIME))
time.sleep(GUARD_TIME)
time_start = time.time()
energy_start = read_energy()
print cmd
print(cmd)
os.system(cmd)
energy_end = read_energy()
time_end = time.time()
stop_energy_reader()
print 'sleep ' + str(GUARD_TIME)
print('sleep ' + str(GUARD_TIME))
time.sleep(GUARD_TIME)
uj = energy_end - energy_start
@ -172,11 +175,11 @@ def execute(base_dir, build_target, renderer, page, profile, trial, layout_threa
f.write("\nPower (W): " + str(watts))
def characterize(build_target, base_dir, (min_layout_threads, max_layout_threads), renderer, page, profile, trials):
def characterize(build_target, base_dir, layout_threads_limits, renderer, page, profile, trials):
"""Run all configurations and capture results.
"""
for layout_thread_count in xrange(min_layout_threads, max_layout_threads + 1):
for trial in xrange(1, trials + 1):
for layout_thread_count in six.moves.xrange(layout_threads_limits[0], layout_threads_limits[1] + 1):
for trial in six.moves.xrange(1, trials + 1):
execute(base_dir, build_target, renderer, page, profile, trial, layout_thread_count)
@ -250,7 +253,7 @@ def main():
trials = args.trials
if os.path.exists(output_dir):
print "Output directory already exists: " + output_dir
print("Output directory already exists: " + output_dir)
sys.exit(1)
os.makedirs(output_dir)

View file

@ -4,6 +4,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import print_function
import sys
import os
from os import path
@ -43,15 +45,15 @@ def execute(base_dir, renderer, page, profile, trial, layout_thread_count):
log_dir = path.join(base_dir, "logs_l" + str(layout_thread_count),
"trial_" + str(trial))
if os.path.exists(log_dir):
print "Log directory already exists: " + log_dir
print("Log directory already exists: " + log_dir)
sys.exit(1)
os.makedirs(log_dir)
# Execute
cmd = get_command(layout_thread_count, renderer, page, profile)
print cmd
print(cmd)
os.system(cmd)
print 'sleep ' + str(GUARD_TIME)
print('sleep ' + str(GUARD_TIME))
time.sleep(GUARD_TIME)
# Write a file that describes this execution
@ -109,7 +111,7 @@ def main():
profile = args.profile
if os.path.exists(output_dir):
print "Output directory already exists: " + output_dir
print("Output directory already exists: " + output_dir)
sys.exit(1)
os.makedirs(output_dir)

View file

@ -4,11 +4,14 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
from __future__ import print_function
import argparse
import matplotlib.pyplot as plt
import numpy as np
import os
from os import path
import six
import sys
import warnings
@ -196,7 +199,7 @@ def plot_trial_time_series(config, trial, trial_data, max_end_time, max_power, o
i = 10
for (p, ts, te, es, ee) in trial_data:
xranges = [(ts[j] / 1000000.0, (te[j] - ts[j]) / 1000000.0) for j in xrange(len(ts))]
xranges = [(ts[j] / 1000000.0, (te[j] - ts[j]) / 1000000.0) for j in six.moves.xrange(len(ts))]
ax1.broken_barh(xranges, (i - 0.5 * width, width))
i += 10
# place a vbar at the final time for this trial
@ -385,20 +388,20 @@ def main():
android = args.android
if not os.path.exists(directory):
print "Input directory does not exist: " + directory
print("Input directory does not exist: " + directory)
sys.exit(1)
if os.path.exists(output_dir):
print "Output directory already exists: " + output_dir
print("Output directory already exists: " + output_dir)
sys.exit(1)
res = process_logs(directory)
if not android:
best = find_best_executions(directory)
print 'Best time:', best[0]
print 'Best energy:', best[1]
print 'Best power:', best[2]
print('Best time:', best[0])
print('Best energy:', best[1])
print('Best power:', best[2])
os.makedirs(output_dir)
plot_all_raw_totals(res, output_dir)