diff options
author | mattcary <mattcary@chromium.org> | 2016-03-23 09:40:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-23 16:41:47 +0000 |
commit | fdd7f55e4218083d927e8de55fb1621c64ab1641 (patch) | |
tree | ef50122b70a2fbf76695f0c575d6d62a405b18e2 /tools/android | |
parent | 220db613792b3fa65361e478ddd00da753e7aa7c (diff) | |
download | chromium_src-fdd7f55e4218083d927e8de55fb1621c64ab1641.zip chromium_src-fdd7f55e4218083d927e8de55fb1621c64ab1641.tar.gz chromium_src-fdd7f55e4218083d927e8de55fb1621c64ab1641.tar.bz2 |
Clovis: remove occurrence counting in ResourceSack.
Now that we've settled on CoreSet this is unused.
Review URL: https://codereview.chromium.org/1830523004
Cr-Commit-Position: refs/heads/master@{#382865}
Diffstat (limited to 'tools/android')
-rw-r--r-- | tools/android/loading/resource_sack.py | 53 | ||||
-rw-r--r-- | tools/android/loading/resource_sack_unittest.py | 28 |
2 files changed, 0 insertions, 81 deletions
diff --git a/tools/android/loading/resource_sack.py b/tools/android/loading/resource_sack.py index 9c174c5..08d5d14 100644 --- a/tools/android/loading/resource_sack.py +++ b/tools/android/loading/resource_sack.py @@ -131,22 +131,6 @@ class GraphSack(object): return 0 return float(len(a & b)) / len(a | b) - def FilterOccurrence(self, tag, filter_from_graph): - """Accumulate filter occurrences for each bag in the graph. - - This can be retrieved under tag for each Bag in the graph. For example, if - FilterContentful marks the nodes of each graph before the first contentful - paint, then FilterOccurrence('contentful', FilterContentful) will count, for - each bag, the fraction of nodes that were before the first contentful paint. - - Args: - tag: the tag to count the filter appearances under. - filter_from_graph: a function graph -> node filter, where node filter - takes a node to a boolean. - """ - for bag in self.bags: - bag.MarkOccurrence(tag, filter_from_graph) - @property def num_graphs(self): return len(self.graph_info) @@ -191,12 +175,6 @@ class Bag(dag.Node): self._relative_costs = [] self._num_critical = 0 - # See MarkOccurrence and GetOccurrence, below. This maps an occurrence - # tag to a list of nodes matching the occurrence. - self._occurence_matches = {} - # Number of nodes seen for each occurrence. - self._occurence_count = {} - @property def url(self): return self._url @@ -254,37 +232,6 @@ class Bag(dag.Node): self._successor_sources[successor_bag].add((graph, node, s)) self._successor_edge_costs[successor_bag].add(graph.EdgeCost(node, s)) - def MarkOccurrence(self, tag, filter_from_graph): - """Mark occurrences for nodes in this bag according to graph_filters. - - Results can be querried by GetOccurrence(). - - Args: - tag: a label for this set of occurrences. - filter_from_graph: a function graph -> node filter, where node filter - takes a node to a boolean. - """ - self._occurence_matches[tag] = 0 - self._occurence_count[tag] = 0 - for graph, nodes in self.graphs.iteritems(): - for n in nodes: - self._occurence_count[tag] += 1 - if filter_from_graph(graph)(n): - self._occurence_matches[tag] += 1 - - def GetOccurrence(self, tag): - """Retrieve the occurrence fraction of a tag. - - Args: - tag: the tag under which the occurrence was counted. This must have been - previously added at least once via AddOccurrence. - - Returns: - A fraction occurrence matches / occurrence node count. - """ - assert self._occurence_count[tag] > 0 - return float(self._occurence_matches[tag]) / self._occurence_count[tag] - @classmethod def _MakeShortname(cls, url): parsed = urlparse.urlparse(url) diff --git a/tools/android/loading/resource_sack_unittest.py b/tools/android/loading/resource_sack_unittest.py index df0fdb7..a4b1a30 100644 --- a/tools/android/loading/resource_sack_unittest.py +++ b/tools/android/loading/resource_sack_unittest.py @@ -66,34 +66,6 @@ class ResourceSackTestCase(unittest.TestCase): self.assertEqual(set(['0/', 'data:fake/content']), set([bag.label for bag in sack.bags])) - def test_Occurrence(self): - # There are two graph shapes. The first one is added to the sack three - # times, and the second once. The second graph has one sibling that doesn't - # appear in the first as well as a new child. - shape1 = [MakeRequest(0, 'null'), MakeRequest(1, 0), MakeRequest(2, 0)] - shape2 = [MakeRequest(0, 'null'), MakeRequest(1, 0), - MakeRequest(3, 0), MakeRequest(4, 1)] - graphs = [TestResourceGraph.FromRequestList(s) - for s in (shape1, shape1, shape1, shape2)] - sack = resource_sack.GraphSack() - for g in graphs: - sack.ConsumeGraph(g) - # Map a graph to a list of nodes that are in its filter. - filter_sets = { - graphs[0]: set([0, 1, 2]), - graphs[1]: set([0, 1, 2]), - graphs[2]: set([0, 1]), - graphs[3]: set([0, 3])} - sack.FilterOccurrence( - 'test', lambda graph: lambda node: - int(node.ShortName()) in filter_sets[graph]) - labels = {bag.label: bag for bag in sack.bags} - self.assertAlmostEqual(1, labels['0/'].GetOccurrence('test'), 3) - self.assertAlmostEqual(0.75, labels['1/'].GetOccurrence('test'), 3) - self.assertAlmostEqual(0.667, labels['2/'].GetOccurrence('test'), 3) - self.assertAlmostEqual(1, labels['3/'].GetOccurrence('test'), 3) - self.assertAlmostEqual(0, labels['4/'].GetOccurrence('test'), 3) - def test_Core(self): # We will use a core threshold of 0.5 to make it easier to define # graphs. Resources 0 and 1 are core and others are not. |