aboutsummaryrefslogtreecommitdiff
path: root/afdo_tools/bisection/afdo_prof_analysis.py
diff options
context:
space:
mode:
authorZhizhou Yang <zhizhouy@google.com>2020-02-11 16:56:57 -0800
committerZhizhou Yang <zhizhouy@google.com>2020-02-13 06:50:19 +0000
commit43c9066b1889baaa0a6077399deb6a4d503551e6 (patch)
treedb4575b4aea577e3da2d7bfb3ac17f386b257733 /afdo_tools/bisection/afdo_prof_analysis.py
parentc4615d189f6b0dc4c116fc0a78ac295f7427170e (diff)
downloadtoolchain-utils-43c9066b1889baaa0a6077399deb6a4d503551e6.tar.gz
toolchain-utils: migrate all in-use projects to python 3
This patch migrates all in-use projects left to python 3. BUG=chromium:1011676 TEST=Passed unittests and launched scripts manually. Change-Id: I7f2de4e1131c05bacfac80667f3064da8adaebfd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2051397 Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Zhizhou Yang <zhizhouy@google.com> Auto-Submit: Zhizhou Yang <zhizhouy@google.com>
Diffstat (limited to 'afdo_tools/bisection/afdo_prof_analysis.py')
-rwxr-xr-xafdo_tools/bisection/afdo_prof_analysis.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/afdo_tools/bisection/afdo_prof_analysis.py b/afdo_tools/bisection/afdo_prof_analysis.py
index 36531106..94e5366b 100755
--- a/afdo_tools/bisection/afdo_prof_analysis.py
+++ b/afdo_tools/bisection/afdo_prof_analysis.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
@@ -109,7 +109,7 @@ class DeciderState(object):
self.state_file)
return
- with open(self.state_file) as f:
+ with open(self.state_file, encoding='utf-8') as f:
try:
data = json.load(f)
except:
@@ -127,7 +127,7 @@ class DeciderState(object):
def save_state(self):
state = {'seed': self.seed, 'accumulated_results': self.accumulated_results}
tmp_file = self.state_file + '.new'
- with open(tmp_file, 'w') as f:
+ with open(tmp_file, 'w', encoding='utf-8') as f:
json.dump(state, f, indent=2)
os.rename(tmp_file, self.state_file)
logging.info('Logged state to %s...', self.state_file)
@@ -270,7 +270,7 @@ def range_search(decider, good, bad, common_funcs, lo, hi):
def find_upper_border(good_copy, funcs, lo, hi, last_bad_val=None):
"""Finds the upper border of problematic range."""
mid = average(lo, hi)
- if mid == lo or mid == hi:
+ if mid in (lo, hi):
return last_bad_val or hi
for func in funcs[lo:mid]:
@@ -288,7 +288,7 @@ def range_search(decider, good, bad, common_funcs, lo, hi):
def find_lower_border(good_copy, funcs, lo, hi, last_bad_val=None):
"""Finds the lower border of problematic range."""
mid = average(lo, hi)
- if mid == lo or mid == hi:
+ if mid in (lo, hi):
return last_bad_val or lo
for func in funcs[lo:mid]:
@@ -428,7 +428,7 @@ def main(flags):
'good_only_functions': gnb_result,
'bad_only_functions': bng_result
}
- with open(flags.analysis_output_file, 'wb') as f:
+ with open(flags.analysis_output_file, 'w', encoding='utf-8') as f:
json.dump(results, f, indent=2)
if flags.remove_state_on_completion:
os.remove(flags.state_file)