Small modifications
This commit is contained in:
15
bench.py
15
bench.py
@@ -11,20 +11,21 @@ async def extract_links(url):
|
||||
for link in soup.find_all('a'):
|
||||
yield urljoin(url, link.get('href'))
|
||||
|
||||
|
||||
async def benchmark(url):
|
||||
# This will still block, because subprocess.run is not async
|
||||
subprocess.run(['hey', '-n', '100', '-c', '10', url])
|
||||
subprocess.run(['hey', '-n', '10000', '-c', '100', url])
|
||||
|
||||
url = 'http://zen.box:9999/http/'
|
||||
url = 'http://localhost:9999/http/'
|
||||
|
||||
async def main():
|
||||
i = 1
|
||||
async for link in extract_links(url):
|
||||
if i > 50:
|
||||
break
|
||||
await benchmark(link)
|
||||
print("BENCHMARKING " + link.replace('/http/', '/'))
|
||||
await benchmark(link.replace('/http/', '/'))
|
||||
i += 1
|
||||
|
||||
print("BENCHMARKING " + link)
|
||||
await benchmark(link)
|
||||
|
||||
|
||||
# Python 3.7+
|
||||
asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user