Using custom duration source #48
-
|
Hello! I love the DX for mitata's testing, and though I realize this may be out of scope for the project, I'd love to be able to stick with the usual really easy-to-use syntax for argument arrays and such but return from my function a duration to use instead of the computed function duration. My use case is specifically with a network API call that returns its own computed duration (without network latency), and being able to compare that would be helpful. If this is currently possible even with a hack, or if there is a clear path towards implementation I could help with, let me know 🙂 Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
current benchmarking logic heavily assumes a lot of things for improving accuracy of local functions, so integrating an external timer would require some kind of manual configuration it would end up being something like bench(function* () {
yield {
heap: false,
counters: false,
manual() {
const t0 = now();
return now() - t0;
},
};
}); |
Beta Was this translation helpful? Give feedback.
-
|
you can now create manual benchmarks (v1.0.34 and newer) (note: concurrency is not available in manual benchmarks) lineplot(() => {
bench('test', function* () {
yield {
heap: false,
counters: false,
budget: 'real',
// or
budget: 'manual',
// budget determines how long the benchmark is run
// manual time budget will only count duration you provide
// real (default) time budget will take into account duration of whole manual() call
[0]() {
return 5000 * 1e6; // 5s in nanoseconds
},
// manual() has to return nanoseconds duration
async manual(p0) {
return p0;
},
};
});
}); |
Beta Was this translation helpful? Give feedback.
you can now create manual benchmarks (v1.0.34 and newer)
(note: concurrency is not available in manual benchmarks)