Lines Matching refs:self
47 def __init__(self, env: Env, argument
55 self.verbose = verbose
56 self.env = env
57 self.protocol = protocol
58 self.server_descr = server_descr
59 self.server_addr = server_addr
60 self.server_port = server_port
61 self._silent_curl = not curl_verbose
62 self._download_parallel = download_parallel
64 def info(self, msg): argument
65 if self.verbose > 0:
69 def handshakes(self) -> Dict[str, Any]: argument
72 self.info('TLS Handshake\n')
76 self.info(f' {authority}...')
79 self.info(f'{ipv}...')
84 curl = CurlClient(env=self.env, silent=self._silent_curl,
85 server_addr=self.server_addr)
87 '--http3-only' if self.protocol == 'h3' else '--http2',
101 self.info('ok.\n')
104 def _make_docs_file(self, docs_dir: str, fname: str, fsize: int): argument
114 def setup_resources(self, server_docs: str, argument
117 label = self.fmt_size(fsize)
119 self._make_docs_file(docs_dir=server_docs,
121 self._make_docs_file(docs_dir=server_docs,
124 def _check_downloads(self, r: ExecResult, count: int): argument
135 def transfer_single(self, url: str, count: int): argument
141 self.info('single...')
143 curl = CurlClient(env=self.env, silent=self._silent_curl,
144 server_addr=self.server_addr)
145 r = curl.http_download(urls=[url], alpn_proto=self.protocol,
148 err = self._check_downloads(r, count)
164 def transfer_serial(self, url: str, count: int): argument
170 self.info('serial...')
172 curl = CurlClient(env=self.env, silent=self._silent_curl,
173 server_addr=self.server_addr)
174 r = curl.http_download(urls=[url], alpn_proto=self.protocol,
177 err = self._check_downloads(r, count)
193 def transfer_parallel(self, url: str, count: int): argument
198 max_parallel = self._download_parallel if self._download_parallel > 0 else count
200 self.info('parallel...')
202 curl = CurlClient(env=self.env, silent=self._silent_curl,
203 server_addr=self.server_addr)
204 r = curl.http_download(urls=[url], alpn_proto=self.protocol,
212 err = self._check_downloads(r, count)
228 def download_url(self, label: str, url: str, count: int): argument
229 self.info(f' {count}x{label}: ')
231 'single': self.transfer_single(url=url, count=10),
234 props['serial'] = self.transfer_serial(url=url, count=count)
235 props['parallel'] = self.transfer_parallel(url=url, count=count)
236 self.info('ok.\n')
239 def downloads(self, count: int, fsizes: List[int]) -> Dict[str, Any]: argument
242 label = self.fmt_size(fsize)
245 scores[label] = self.download_url(label=label, url=url, count=count)
248 def _check_uploads(self, r: ExecResult, count: int): argument
261 def upload_single(self, url: str, fpath: str, count: int): argument
267 self.info('single...')
269 curl = CurlClient(env=self.env, silent=self._silent_curl,
270 server_addr=self.server_addr)
271 r = curl.http_put(urls=[url], fdata=fpath, alpn_proto=self.protocol,
273 err = self._check_uploads(r, count)
289 def upload_serial(self, url: str, fpath: str, count: int): argument
295 self.info('serial...')
297 curl = CurlClient(env=self.env, silent=self._silent_curl,
298 server_addr=self.server_addr)
299 r = curl.http_put(urls=[url], fdata=fpath, alpn_proto=self.protocol,
301 err = self._check_uploads(r, count)
317 def upload_parallel(self, url: str, fpath: str, count: int): argument
324 self.info('parallel...')
326 curl = CurlClient(env=self.env, silent=self._silent_curl,
327 server_addr=self.server_addr)
328 r = curl.http_put(urls=[url], fdata=fpath, alpn_proto=self.protocol,
334 err = self._check_uploads(r, count)
350 def upload_url(self, label: str, url: str, fpath: str, count: int): argument
351 self.info(f' {count}x{label}: ')
353 'single': self.upload_single(url=url, fpath=fpath, count=10),
356 props['serial'] = self.upload_serial(url=url, fpath=fpath, count=count)
357 props['parallel'] = self.upload_parallel(url=url, fpath=fpath, count=count)
358 self.info('ok.\n')
361 def uploads(self, count: int, fsizes: List[int]) -> Dict[str, Any]: argument
366 label = self.fmt_size(fsize)
368 fpaths[label] = self._make_docs_file(docs_dir=self.env.gen_dir,
372 scores[label] = self.upload_url(label=label, url=url, fpath=fpath,
376 def do_requests(self, url: str, count: int, max_parallel: int = 1): argument
389 self.info(f'{max_parallel}...')
391 curl = CurlClient(env=self.env, silent=self._silent_curl,
392 server_addr=self.server_addr)
393 r = curl.http_download(urls=[url], alpn_proto=self.protocol, no_save=True,
415 def requests_url(self, url: str, count: int): argument
416 self.info(f' {url}: ')
420 props[str(m)] = self.do_requests(url=url, count=count, max_parallel=m)
421 self.info('ok.\n')
424 def requests(self, req_count) -> Dict[str, Any]: argument
428 '10KB': self.requests_url(url=url, count=req_count),
431 def score(self, argument
439 self.info(f"scoring {self.protocol} against {self.server_descr}\n")
441 if self.protocol == 'h3':
443 if not self.env.have_h3_curl():
446 if self.env.curl_uses_lib(lib):
449 elif self.protocol == 'h2':
451 if not self.env.have_h2_curl():
454 if self.env.curl_uses_lib(lib):
457 elif self.protocol == 'h1' or self.protocol == 'http/1.1':
460 p['implementation'] = 'hyper' if self.env.curl_uses_lib('hyper')\
470 'curl': self.env.curl_fullname(),
471 'os': self.env.curl_os(),
473 'server': self.server_descr,
476 score['handshakes'] = self.handshakes()
478 score['downloads'] = self.downloads(count=download_count,
481 score['uploads'] = self.uploads(count=upload_count,
484 score['requests'] = self.requests(req_count=req_count)
485 self.info("\n")
488 def fmt_ms(self, tval): argument
491 def fmt_size(self, val): argument
501 def fmt_mbs(self, val): argument
504 def fmt_reqs(self, val): argument
507 def print_score(self, score): argument