MCPcopy Index your code
hub / github.com/nodejs/node / run_site

Function run_site

deps/v8/tools/callstats.py:162–229  ·  view source on GitHub ↗
(site, domain, args, timeout=None)

Source from the content-addressed store, hash-verified

160 ]
161
162def run_site(site, domain, args, timeout=None):
163 print("="*80)
164 print("RUNNING DOMAIN %s" % domain)
165 print("="*80)
166 result_template = "{domain}#{count}.txt" if args.repeat else "{domain}.txt"
167 count = 0
168 if timeout is None: timeout = args.timeout
169 if args.replay_wpr:
170 timeout *= 1 + args.refresh
171 timeout += 1
172 retries_since_good_run = 0
173 while count == 0 or args.repeat is not None and count < args.repeat:
174 count += 1
175 result = result_template.format(domain=domain, count=count)
176 retries = 0
177 while args.retries is None or retries < args.retries:
178 retries += 1
179 try:
180 if args.user_data_dir:
181 user_data_dir = args.user_data_dir
182 else:
183 user_data_dir = tempfile.mkdtemp(prefix="chr_")
184 js_flags = "--runtime-call-stats"
185 if args.replay_wpr: js_flags += " --allow-natives-syntax"
186 if args.js_flags: js_flags += " " + args.js_flags
187 chrome_flags = get_chrome_flags(js_flags, user_data_dir)
188 if args.replay_wpr:
189 chrome_flags += get_chrome_replay_flags(args)
190 else:
191 chrome_flags += [ "--single-process", ]
192 if args.chrome_flags:
193 chrome_flags += args.chrome_flags.split()
194 cmd_args = [
195 "timeout", str(timeout),
196 args.with_chrome
197 ] + chrome_flags + [ site ]
198 print("- " * 40)
199 print_command(cmd_args)
200 print("- " * 40)
201 with open(result, "wt") as f:
202 with open(args.log_stderr or os.devnull, 'at') as err:
203 status = subprocess.call(cmd_args, stdout=f, stderr=err)
204 # 124 means timeout killed chrome, 0 means the user was bored first!
205 # If none of these two happened, then chrome apparently crashed, so
206 # it must be called again.
207 if status != 124 and status != 0:
208 print("CHROME CRASHED, REPEATING RUN");
209 continue
210 # If the stats file is empty, chrome must be called again.
211 if os.path.isfile(result) and os.path.getsize(result) > 0:
212 if args.print_url:
213 with open(result, "at") as f:
214 print(file=f)
215 print("URL: {}".format(site), file=f)
216 retries_since_good_run = 0
217 break
218 if retries_since_good_run > MAX_NOF_RETRIES:
219 # Abort after too many retries, no point in ever increasing the

Callers 1

do_runFunction · 0.85

Calls 10

get_chrome_flagsFunction · 0.85
get_chrome_replay_flagsFunction · 0.85
strFunction · 0.85
print_commandFunction · 0.85
mkdtempMethod · 0.80
printFunction · 0.70
formatMethod · 0.65
openFunction · 0.50
splitMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…