Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Seemingly unecessary delay in Pool.getOutputAmount (also getInputAmount and swap) #175

Open
NoUJoe opened this issue Jun 7, 2023 · 1 comment

Comments

@NoUJoe
Copy link

NoUJoe commented Jun 7, 2023

Been testing Pool. Long story short, I discovered something odd when timing the performance of some functions.

I've made a gist for replication:

https://gist.github.com/NoUJoe/d57b3d478767dd409bab7e8f6aff44e0.js

The code sets up a pool, and then calls getOutputAmount 4 times, measuring the time from execution to the promise resolving. When all 4 have finished, it will then log the total time taken. Here's an example result:

o4 232
o2 297
o3 337
o1 347
Total time 348

o1 / o2 / o3 / o4 is each getOutputAmount call and Total time is... y'know, total time. All in MS

I know getOutputAmount is async for data retrieval reasons, like web calls etc. But all data used in my example is all local, no network requests or anything. So execution should be pretty synchronous.

But as we can see, total time is about the same time as the longest getOutputAmount call and not the sum of all calls, indicating there's some sort of delay happening somewhere.

@Florian-S-A-W
Copy link

The calls are executed simultaneously, thats also the point of making the function async as it doesn't rely on any network requests.
So the total time is the longest execution + 1ms for everything else.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants