-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asyncio vs purely synchronous performance #76
Comments
0.5.0 Release (https://github.com/shazamio/ShazamIO/releases/tag/0.5.0) ! Test 1. async def main():
t1 = time.time()
for i in range(10):
new_version_path = await shazam.recognize("data/dora.ogg")
serialized_new_path = Serialize.full_track(new_version_path)
print(serialized_new_path)
t2 = time.time()
print(t2 - t1)
# 7.2795631885528564 - recognize_song (OLD VERSION)
# 3.6113240718841553 - recognize (NEW VERSION) Test 2. async def test_old(shazam):
new_version_path = await shazam.recognize_song("data/dora.ogg")
serialized_new_path = Serialize.full_track(new_version_path)
print(serialized_new_path)
async def test_new(shazam):
new_version_path = await shazam.recognize("data/dora.ogg")
serialized_new_path = Serialize.full_track(new_version_path)
print(serialized_new_path)
async def main():
shazam = Shazam()
t1 = time.time()
a = asyncio.gather(*[test_old(shazam) for _ in range(10)])
a = asyncio.gather(*[test_new(shazam) for _ in range(20)])
await a
t2 = time.time()
print(t2-t1)
# recognize_song - 5.2275474071502686
# recognize - 0.5232067108154297
|
This was referenced Feb 23, 2024
Closed
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I made a small experiment to understand the benefit of using asyncio but so far I found that there's no improvement over making synchronous requests to the API. It takes around 4 seconds for one request and the total time for the program scales with the number of calls. I've even made each request run in its own thread but the result was still the same. I am quite confused by this behaviour.
Does anyone have insights into this ?
The text was updated successfully, but these errors were encountered: