Skip to content

Instantly share code, notes, and snippets.

@lega911
Created January 13, 2026 20:44
Show Gist options
  • Select an option

  • Save lega911/166954a6e74b213b717a4c4166184d59 to your computer and use it in GitHub Desktop.

Select an option

Save lega911/166954a6e74b213b717a4c4166184d59 to your computer and use it in GitHub Desktop.
switch test
# taskset 0x00000001 python3 ./async.py
import asyncio
import time
value = 0
COUNT = 200_000_000
def count():
global value
value += 1
async def acount():
global value
value += 1
async def loop():
for _ in range(100):
count()
async def main():
start = time.time()
while value < COUNT:
await loop()
# await acount()
print(value, time.time() - start)
asyncio.run(main())
# taskset 0x00000001 python3 ./sync.py & x 8
import time
start = time.time()
value = 0
COUNT = 200_000_000 // 8
# COUNT = 200_000_000
def count():
global value
value += 1
def loop():
for _ in range(COUNT):
count()
loop()
print(value, time.time() - start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment