package com.perforce.ts.rest; import java.util.Date; /** * * * Simple timer. * call start(), do stuff, call stop(); * * Not thread safe. * * @author jbrown */ public final class TimeCommand { private long start = 0; private long end = 0; /** * start the clock */ public void start() { Date now = new Date(); start = now.getTime(); end = 0; } /** * stop the clock * * @return number of milliseconds between start and stop */ public long stop() { Date now = new Date(); end = now.getTime(); return (end - start); } /** * Retrieve milliseconds * * @return number of milliseconds between start and stop */ public long getMilliseconds() { return (end - start); } // diff time as string @Override public String toString() { if ( end == 0 ) { stop(); } return "Time[" + getMilliseconds() + " ms]"; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 24980 | Joel Brown |
Add query functionalty for testing query response times. Code pattern matches 2018.1 p4dtg's jira-rest plugin. |