-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasyncio.py
More file actions
30 lines (23 loc) · 803 Bytes
/
asyncio.py
File metadata and controls
30 lines (23 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import asyncio
from lib import generate_valid_urls, get_dir_name
from runner import program_runner
async def count_char_bytes(url:str):
# to make it takes more time
char_bytes = 0
for char in url:
char_bytes += len(char.encode())
return char_bytes
async def main():
total_bytes = 0
for url in generate_valid_urls(1_00_000):
total_bytes += await count_char_bytes(url)
return total_bytes
if __name__ == "__main__":
def execute():
return asyncio.run(main())
program_runner(
execute,
"asyncio_data",
get_dir_name(__file__),
descr="Cpu bound execution with asyncio. The experiment count bytes per characteres for 1_00_000 generated urls. The returned_value represents the total bytes of the operation."
)