Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Pattern: How to measure UI response time?
Pattern: How to measure UI response time? [message #520683] Sun, 14 March 2010 05:19
Ralf Ebert is currently offline Ralf Ebert
Messages: 168
Registered: July 2009
Senior Member
Hi,

I was just wondering: How would one test that something is executed in a background thread
and the UI stays responsive? I did it the following way, is there a better solution for this?

StopWatch watch = new StopWatch("UI response time");
someButton.click();
watch.assertDurationLessThanMs(100);

--------------

public class StopWatch {

private final String name;
private final long startTime;

public StopWatch(String name) {
this.name = name;
this.startTime = System.currentTimeMillis();
}

public void assertDurationLessThanMs(long maxResponseTime) {
long duration = getDuration();
if (duration > maxResponseTime) {
throw new RuntimeException(name + " was " + duration + " ms, > than " + maxResponseTime
+ " ms");
}
}

public long getDuration() {
return System.currentTimeMillis() - startTime;
}

}

Greetings,

Ralf


--
http://www.ralfebert.de/blog/eclipsercp/
Previous Topic:Create TestSuit
Next Topic:Tests freeze on cocoa / x86_64
Goto Forum:
  


Current Time: Sat Jul 26 07:22:33 EDT 2014

Powered by FUDForum. Page generated in 0.02453 seconds