Measuring response time question

I’m trying to measure the time it takes to render the next page after submitting some data. To get the timing, what I’m doing is:
Clicking the Submit button
Starting the timer
Waiting for the Expected Condition (presence of element available on the next page).
Subtract the start time from the current time.

My code is:

long start;
driver.findElementById(“submit”).click();
start = System.currentTimeMillis()
new WebDriverWait(driver, 15).until(ExpectedConditions.presenceOfElementLocated(By.id(“order_id”)));
System.out.println((System.currentTimeMillis() - start) + “ Order submission time");

Questions- Is my time calculation logic correct? Also, is my “wait” line the right trigger to stop the time calculation?
When I run this test via Appium I’m getting response times of around 3 seconds, but whenever I eyeball the response time, it takes about half that time so I’m thinking that maybe I’m not coding this right. I’m running this test on an attached Android device so is it possible the USB connectivity is slowing the response times?

Your logic is correct, your implementation is less so. Appium is not useful for performance testing. If you find you need to do this anyway, I would recommend not using the element location methods. We rolled our own methods which does a page source dump (which is very quick, surprisingly), then we convert that to a string and check to see if the desired element/value is present.

Do not use functional testing tool with performance testing. Its not good approach.

1 Like

OK, thanks for the feedback.