Conversation
| const ret = fn() | ||
| if (ret?.then) await ret; | ||
|
|
||
| const d = process.hrtime.bigint() - s |
There was a problem hiding this comment.
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.
It is more precise then performance.now and I got this from the node repository benchmark code.
There was a problem hiding this comment.
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 |
|
@mauriciolauffer the primary benefit of this integration is the setup that It provides the same portability that all the other tests provide. If you already have a test setup that works with both It is not required to use these APIs to write performance tests. If customers are already using other performance testing tools they can still keep using them. This PR is the first step in the process of improving performance measurement capabilities in the CAP framework. The reason |
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.