Skip to main content


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 09:19
Ralf Ebert is currently offline Ralf EbertFriend
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: Thu Mar 28 15:28:48 GMT 2024

Powered by FUDForum. Page generated in 0.03504 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top