import httpx
import asyncio
async def count_https_in_web_pages():
with open('towebsite.txt', 'r', encoding='utf-8') as f:
urls = [line.strip() for line in f.readlines()]
async with httpx.AsyncClient() as client:
tasks = (client.get(url) for url in urls)
reqs = await asyncio.gather(*tasks)
htmls = [req.text for req in reqs]
htmls = []
for url in urls:
htmls = htmls + [requests.get(url).text]
def main():
import cProfile
import pstats
with cProfile.Profile() as pr:
asyncio.run(count_https_in_web_pages())
stats = pstats.Stats(pr)
stats.sort_stats(pstats.SortKey.TIME)
stats.dump_stats(filename='needs_profiling.prof')
//this file is binary file of profiling report, which is visible at terminal with `snakeviz ./nees_profiling.prof` this will generate report as webpage and share the url.
Last active
February 18, 2022 05:24
-
-
Save mhimanshu0101/4e674ef666922c5ce0e761cbffae2219 to your computer and use it in GitHub Desktop.
Performance testing of Python code using cProfile library with sankeviz to generate report as webpage
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment