Closed therealbrad closed 2 years ago
@therealbrad thanks for your request! The power of performance-total is that it gives you full statistic results on a batch of data, which is the only true way to analyze performance of a scenario. What you're looking for is achievable, for example, by doing this:
const loginStart = Date.now();
await expect(HomePage).toBeDisplayedInViewport();
const loginEnd = Date.now();
// Home Page is displayed within 1 second.
await expect(loginEnd - loginStart).toBeLessThan(1000);
If you don't find this solution satisfying, we can try to refine the request.
@tzurp Yes, I am collecting the performance data in a report, but I also want to fail the test if a performance metric is outside of some bounds. Since the info already exists in the performancetotal
object, I figured I could just access that instead of making my own.
@therealbrad I added an option to get the timespan for a specific sample (in v2.1.2):
const timeSpan = performancetotal.getSampleTime("YourPerformanceTag");
.
If the tag is not found or the call is taking place before sampleEnd
, it would return 0.
Thanks!
Tzur
@tzurp Thank you! Just what I was looking for.
@tzurp
Actually I was stuck somewhere on this method and wanted to discuss with you before raising a bug to make sure am I missing anything by the output of this method: getSampleTime()
This are details from one of my performance test case: index: 1, test case label: abcd, brName: general, avgTime: 20346, sem: 10327, repeats: 3, minValue: 8698, maxValue: 40941
based on this values can you please provide me the o/p value by this method ? lemme know if you need more data. Thanks!
@jt-brevitaz getSampleTime() gives you the current single performance measurement and it should be used for very specific needs. Most users don't use this feature because a single value can't be statistically analyzed.
@tzurp Yeah, but I want to know how it calculates time.
@jt-brevitaz sure, it simply returns the time gap of the current performance pair (start/end). Let's say you measured some event and want to get the value in your test, then you can simply use getSampleTime.
I'd like to make assertions that samples fall within a specific amount of time. Something like:
Maybe there's already a way to do this and I'm missing it?