| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from collections import defaultdict | 5 from collections import defaultdict |
| 6 | 6 |
| 7 from common.diff import ChangeType | 7 from common.diff import ChangeType |
| 8 from common.git_repository import GitRepository | 8 from common.git_repository import GitRepository |
| 9 from common.http_client_appengine import HttpClientAppengine | 9 from common.http_client_appengine import HttpClientAppengine |
| 10 from crash import crash_util | 10 from crash import crash_util |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 """Finds culprit results for crash. | 205 """Finds culprit results for crash. |
| 206 | 206 |
| 207 Args: | 207 Args: |
| 208 stacktrace (Stactrace): Parsed Stactrace object. | 208 stacktrace (Stactrace): Parsed Stactrace object. |
| 209 regression_deps_rolls (dict): Maps dep_path to DependencyRoll in | 209 regression_deps_rolls (dict): Maps dep_path to DependencyRoll in |
| 210 regression range. | 210 regression range. |
| 211 crashed_deps (dict of Dependencys): Represents all the dependencies of | 211 crashed_deps (dict of Dependencys): Represents all the dependencies of |
| 212 crashed revision. | 212 crashed revision. |
| 213 | 213 |
| 214 Returns: | 214 Returns: |
| 215 List of dicts of culprit results, sorted by confidence from highest to | 215 List of Results, sorted by confidence from highest to lowest. |
| 216 lowest. | |
| 217 """ | 216 """ |
| 218 if not regression_deps_rolls: | 217 if not regression_deps_rolls: |
| 219 return [] | 218 return [] |
| 220 | 219 |
| 221 # Findit will only analyze the top n frames in each callstacks. | 220 # Findit will only analyze the top n frames in each callstacks. |
| 222 stack_trace = Stacktrace([ | 221 stack_trace = Stacktrace([ |
| 223 CallStack(stack.priority, stack.format_type, stack[:top_n]) | 222 CallStack(stack.priority, stack.format_type, stack[:top_n]) |
| 224 for stack in stacktrace]) | 223 for stack in stacktrace]) |
| 225 | 224 |
| 226 # We are only interested in the deps in crash stack (the callstack that | 225 # We are only interested in the deps in crash stack (the callstack that |
| (...skipping 15 matching lines...) Expand all Loading... |
| 242 | 241 |
| 243 aggregator = Aggregator([TopFrameIndex(), MinDistance()]) | 242 aggregator = Aggregator([TopFrameIndex(), MinDistance()]) |
| 244 | 243 |
| 245 map(aggregator.ScoreAndReason, results) | 244 map(aggregator.ScoreAndReason, results) |
| 246 | 245 |
| 247 # Filter all the 0 confidence results. | 246 # Filter all the 0 confidence results. |
| 248 results = filter(lambda r: r.confidence != 0, results) | 247 results = filter(lambda r: r.confidence != 0, results) |
| 249 if not results: | 248 if not results: |
| 250 return [] | 249 return [] |
| 251 | 250 |
| 252 sorted_results = sorted([result.ToDict() for result in results], | 251 sorted_results = sorted(results, key=lambda r: -r.confidence) |
| 253 key=lambda r: -r['confidence']) | |
| 254 | 252 |
| 255 if sorted_results[0]['confidence'] > 0.999: | 253 if sorted_results[0].confidence > 0.999: |
| 256 return sorted_results[:1] | 254 return sorted_results[:1] |
| 257 | 255 |
| 258 return sorted_results[:3] | 256 return sorted_results[:3] |
| OLD | NEW |