aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool/binary_search_perforce.py
diff options
context:
space:
mode:
authorCassidy Burden <cburden@google.com>2016-06-10 11:20:28 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-06-13 13:48:29 -0700
commitbdd09b15b0ac1e60b3495e3698cb411926b21f9c (patch)
tree088b2698676467d8cd2ebcf99581233c3f47d9eb /binary_search_tool/binary_search_perforce.py
parent333fe383dcd0c35981a5473bc913d07b52c310a1 (diff)
downloadtoolchain-utils-bdd09b15b0ac1e60b3495e3698cb411926b21f9c.tar.gz
[crosperf] Update binary search scripts to use same logger.
TEST=Run with package bisector, logs no longer overwritten BUG=619081 Change-Id: I0f9b76a2b08c98b53a7e7a98b52ba4a1f02a0276 Reviewed-on: https://chrome-internal-review.googlesource.com/263946 Commit-Ready: Cassidy Burden <cburden@google.com> Tested-by: Cassidy Burden <cburden@google.com> Reviewed-by: Cassidy Burden <cburden@google.com> Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'binary_search_tool/binary_search_perforce.py')
-rwxr-xr-xbinary_search_tool/binary_search_perforce.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/binary_search_tool/binary_search_perforce.py b/binary_search_tool/binary_search_perforce.py
index 39da8e2b..0ec78768 100755
--- a/binary_search_tool/binary_search_perforce.py
+++ b/binary_search_tool/binary_search_perforce.py
@@ -63,7 +63,7 @@ class BinarySearchPoint(object):
class BinarySearcher(object):
"""Class of binary searcher."""
- def __init__(self):
+ def __init__(self, logger_to_set=None):
self.sorted_list = []
self.index_log = []
self.status_log = []
@@ -72,6 +72,10 @@ class BinarySearcher(object):
self.points = {}
self.lo = 0
self.hi = 0
+ if logger_to_set is not None:
+ self.logger = logger_to_set
+ else:
+ self.logger = logger.GetLogger();
def SetSortedList(self, sorted_list):
assert len(sorted_list) > 0
@@ -89,7 +93,7 @@ class BinarySearcher(object):
(self.sorted_list[self.current],
self.current,
status))
- logger.GetLogger().LogOutput(message, print_to_console=verbose)
+ self.logger.LogOutput(message, print_to_console=verbose)
assert status == 0 or status == 1 or status == 2
self.index_log.append(self.current)
self.status_log.append(status)
@@ -104,7 +108,7 @@ class BinarySearcher(object):
self.lo = self.current + 1
elif status == 1:
self.hi = self.current
- logger.GetLogger().LogOutput("lo: %d hi: %d\n" % (self.lo, self.hi))
+ self.logger.LogOutput("lo: %d hi: %d\n" % (self.lo, self.hi))
self.current = (self.lo + self.hi)/2
if self.lo == self.hi:
@@ -112,13 +116,13 @@ class BinarySearcher(object):
" at index: %d" %
(self.sorted_list[self.current],
self.lo))
- logger.GetLogger().LogOutput(message)
+ self.logger.LogOutput(message)
return True
for index in range(self.lo, self.hi):
if index not in self.skipped_indices:
return False
- logger.GetLogger().LogOutput(
+ self.logger.LogOutput(
"All skipped indices between: %d and %d\n" % (self.lo, self.hi),
print_to_console=verbose)
return True
@@ -167,12 +171,12 @@ class BinarySearcher(object):
message = ("Estimated tries: min: %d max: %d\n" %
(1 + math.log(self.hi - self.lo, 2),
self.hi - self.lo - len(self.skipped_indices)))
- logger.GetLogger().LogOutput(message, print_to_console=verbose)
+ self.logger.LogOutput(message, print_to_console=verbose)
message = ("lo: %d hi: %d current: %d version: %s\n" %
(self.lo, self.hi, self.current,
self.sorted_list[self.current]))
- logger.GetLogger().LogOutput(message, print_to_console=verbose)
- logger.GetLogger().LogOutput(str(self), print_to_console=verbose)
+ self.logger.LogOutput(message, print_to_console=verbose)
+ self.logger.LogOutput(str(self), print_to_console=verbose)
return self.sorted_list[self.current]
def SetLoRevision(self, lo_revision):