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

Side by Side Diff: tools/android/loading/processing.py

Issue 1619713002: Upgrade analyze.py and related scripts to new world order. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 11 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
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 import json
5 import os 6 import os
6 import os.path 7 import os.path
7 import sys 8 import sys
8 9
9 import log_parser
10 import loading_model 10 import loading_model
11 import loading_trace
11 12
12 13
13 def SitesFromDir(directory): 14 def SitesFromDir(directory):
14 """Extract sites from a data directory. 15 """Extract sites from a data directory.
15 16
16 Based on ./analyze.py fetch file name conventions. We assume each site 17 Based on ./analyze.py fetch file name conventions. We assume each site
17 corresponds to two files, <site>.json and <site>.json.cold, and that no other 18 corresponds to two files, <site>.json and <site>.json.cold, and that no other
18 kind of file appears in the data directory. 19 kind of file appears in the data directory.
19 20
20 Args: 21 Args:
(...skipping 24 matching lines...) Expand all
45 46
46 Based on ./analyze.py fetch file name conventions. 47 Based on ./analyze.py fetch file name conventions.
47 48
48 Args: 49 Args:
49 datadir: the directory containing site JSON data. 50 datadir: the directory containing site JSON data.
50 site: a site string. 51 site: a site string.
51 52
52 Returns: 53 Returns:
53 A loading model object. 54 A loading model object.
54 """ 55 """
55 return loading_model.ResourceGraph(log_parser.FilterRequests( 56 with file(os.path.join(datadir, site + '.json')) as f:
56 log_parser.ParseJsonFile(os.path.join(datadir, site + '.json')))) 57 return loading_model.ResourceGraph(loading_trace.LoadingTrace.FromJsonDict(
58 json.load(f)))
57 59
58 60
59 def ColdGraph(datadir, site): 61 def ColdGraph(datadir, site):
60 """Return a loading model graph for the cold pull of site. 62 """Return a loading model graph for the cold pull of site.
61 63
62 Based on ./analyze.py fetch file name conventions. 64 Based on ./analyze.py fetch file name conventions.
63 65
64 Args: 66 Args:
65 datadir: the directory containing site JSON data. 67 datadir: the directory containing site JSON data.
66 site: a site string. 68 site: a site string.
67 69
68 Returns: 70 Returns:
69 A loading model object. 71 A loading model object.
70 """ 72 """
71 return loading_model.ResourceGraph(log_parser.FilterRequests( 73 with file(os.path.join(datadir, site + '.json.cold')) as f:
72 log_parser.ParseJsonFile(os.path.join(datadir, site + '.json.cold')))) 74 return loading_model.ResourceGraph(loading_trace.LoadingTrace.FromJsonDict(
75 json.load(f)))
OLDNEW
« no previous file with comments | « tools/android/loading/process_request_log.py ('k') | tools/android/loading/request_dependencies_lens.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698