(N, url)
| 550 | print(format % ('keepalive readline', m.hexdigest())) |
| 551 | |
| 552 | def comp(N, url): |
| 553 | print(' making %i connections to:\n %s' % (N, url)) |
| 554 | |
| 555 | sys.stdout.write(' first using the normal urllib handlers') |
| 556 | # first use normal opener |
| 557 | opener = _urllib.request.build_opener() |
| 558 | _urllib.request.install_opener(opener) |
| 559 | t1 = fetch(N, url) |
| 560 | print(' TIME: %.3f s' % t1) |
| 561 | |
| 562 | sys.stdout.write(' now using the keepalive handler ') |
| 563 | # now install the keepalive handler and try again |
| 564 | opener = _urllib.request.build_opener(HTTPHandler()) |
| 565 | _urllib.request.install_opener(opener) |
| 566 | t2 = fetch(N, url) |
| 567 | print(' TIME: %.3f s' % t2) |
| 568 | print(' improvement factor: %.2f' % (t1/t2, )) |
| 569 | |
| 570 | def fetch(N, url, delay=0): |
| 571 | import time |
no test coverage detected
searching dependent graphs…