- 
        Couldn't load subscription status. 
- Fork 3
feat: performance measurement APIs #20
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
base: main
Are you sure you want to change the base?
Conversation
| const ret = fn() | ||
| if (ret?.then) await ret; | ||
|  | ||
| const d = process.hrtime.bigint() - s | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just out of curiosity, whats the advantage of this over:
const time = process.hrtime() // nano precision
…
const diff = process.hrtime(time)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more precise then performance.now and I got this from the node repository benchmark code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know hrtime is more precise, I was just wondering why we need the bigint() API here. Also the diff calculation can be done by the function itself (but it yields a [seconds, nanoseconds] tuple).
Smt like this:
- const d = process.hrtime.bigint() - s
+ const d = process.hrtime(s)based on cap-js/cds-test#20 (and some local tweaks) preferred over #1329
| Hi @chgeo / @danjoa I tried this out in a small benchmarking suite for cqn4sql. Does anything speak against merging this? | 
| What's the value in embedding  | 
This PR adds a new
perfproperty to thecds.testAPI. Which is a wrapper around the commonly usedautocannonnode module. Which allows developers to measure the performance of their endpoints. To make the API as simple to use as possible the APIs haveaxiosintegration. Which means that by default the same baseurlis used byperfas it currently used byaxios.Additionally
perfintroduces thefnAPI. Which accepts a callback function which will be measured in a similar way as all theautocannonAPIs are. Providing flexibility for not just measuring http request performance, but also for measuring the performance of any javascript function. For the use cases where multiple requests have to be chained together thefncallback can beasyncand the promise will be awaited and theconnectionsconfiguration ofautocannonwill apply so that if thereasyncfunction detaches from the event loop. It will trigger multiple parallel calls to the callback function.