Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: appengine/findit/crash/scorers/top_frame_index.py

Issue 1861373003: [Findit] Initial code of findit for crash. Add scorers to apply heuristic rules. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix nits and rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 """TopFrameIndex scorer applies to all Result objects.
6
7 It represents a heuristic rule:
8 The less the top frame index (this result changed) is, the higher score.
9 """
10
11 from crash.scorers.scorer import Scorer
12
13 # TODO(katesonia): Move this to the config saved in datastore.
14 _MAX_TOP_N_FRAMES = 7
15 _INFINITY = 1000
16
17
18 class TopFrameIndex(Scorer):
19
20 def __init__(self, max_top_n=_MAX_TOP_N_FRAMES):
21 self.max_top_n = max_top_n
22
23 def GetMetric(self, result):
24 if not result.file_to_stack_infos:
25 return None
26
27 top_frame_index = _INFINITY
28 for _, stack_infos in result.file_to_stack_infos.iteritems():
29 for frame, _ in stack_infos:
30 top_frame_index = min(top_frame_index, frame.index)
31
32 return top_frame_index
33
34 def Score(self, top_frame_index):
35 # TODO(katesonia): experiment the model and parameters later.
36 if top_frame_index < self.max_top_n:
37 return 1 - top_frame_index / float(self.max_top_n)
38
39 return 0
40
41 def Reason(self, top_frame_index, score):
42 if score == 0:
43 return ''
44
45 return 'Top frame changed is frame #%d' % top_frame_index
OLDNEW
« no previous file with comments | « appengine/findit/crash/scorers/test/top_frame_index_test.py ('k') | appengine/findit/crash/test/crash_test_suite.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698