Skip to content

Instantly share code, notes, and snippets.

@acu192
Created October 1, 2021 16:50
Show Gist options
  • Save acu192/7697ead59fc34a017043a1e13b9e6703 to your computer and use it in GitHub Desktop.
Save acu192/7697ead59fc34a017043a1e13b9e6703 to your computer and use it in GitHub Desktop.
import sys
import time
import requests
from threading import Thread
URL = 'http://localhost:8003/api/temp/sleep'
def get():
req = requests.get(URL)
res = req.json()
assert res['success']
return res
def main(n):
begin = time.time()
threads = [Thread(target=get) for _ in range(n)]
for t in threads:
t.start()
for t in threads:
t.join()
end = time.time()
print(f'Took: {end - begin:.2} seconds')
if __name__ == '__main__':
main(int(sys.argv[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment