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

Unified Diff: tools/resource_prefetch_predictor/prefetch_predictor_tool.py

Issue 2385173002: predictors: Take the priority into account for scoring resources. (Closed)
Patch Set: Address comments. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor_tables_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/resource_prefetch_predictor/prefetch_predictor_tool.py
diff --git a/tools/resource_prefetch_predictor/prefetch_predictor_tool.py b/tools/resource_prefetch_predictor/prefetch_predictor_tool.py
index fe7976414bc3f9e3e5b89e809ae59fcaae5b63ff..0e9657a897f1623b61c235c7f60e59ff082728d3 100755
--- a/tools/resource_prefetch_predictor/prefetch_predictor_tool.py
+++ b/tools/resource_prefetch_predictor/prefetch_predictor_tool.py
@@ -31,13 +31,23 @@ class Entry(object):
self.score = self._Score()
def _Score(self):
- """Mirrors ResourcePrefetchPredictorTables::ResourceRow::UpdateScore."""
- multiplier = 1
+ """Mirrors ResourcePrefetchPredictorTables::ComputeResourceScore."""
+ priority_multiplier = 1
+ type_multiplier = 1
+
+ if self.proto.priority == ResourceData.REQUEST_PRIORITY_HIGHEST:
+ priority_multiplier = 3
+ elif self.proto.priority == ResourceData.REQUEST_PRIORITY_MEDIUM:
+ priority_multiplier = 2
+
if self.proto.resource_type in (ResourceData.RESOURCE_TYPE_STYLESHEET,
- ResourceData.RESOURCE_TYPE_SCRIPT,
- ResourceData.RESOURCE_TYPE_FONT_RESOURCE):
- multiplier = 2
- return multiplier * 100 - self.proto.average_position
+ ResourceData.RESOURCE_TYPE_SCRIPT):
+ type_multiplier = 3
+ elif self.proto.resource_type == ResourceData.RESOURCE_TYPE_FONT_RESOURCE:
+ type_multiplier = 2
+
+ return (100 * (priority_multiplier * 100 + type_multiplier * 10)
+ - self.proto.average_position)
@classmethod
def FromRow(cls, row):
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor_tables_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698