Small modifications

This commit is contained in:
Ben Sarmiento
2023-11-29 00:44:57 +01:00
parent 1120ada9af
commit 7badbc50dc
3 changed files with 16 additions and 11 deletions

View File

@@ -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())