本文整理了Java中org.apache.commons.lang.time.StopWatch.start()
方法的一些代码示例,展示了StopWatch.start()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StopWatch.start()
方法的具体详情如下:
包路径:org.apache.commons.lang.time.StopWatch
类名称:StopWatch
方法名:start
[英]Start the stopwatch.
This method starts a new timing session, clearing any previous values.
[中]启动秒表。
此方法启动一个新的计时会话,清除所有以前的值。
代码示例来源:origin: stackoverflow.com
StopWatch stopWatch = new StopWatch("My Stop Watch");
stopWatch.start("initializing");
Thread.sleep(2000); // simulated work
stopWatch.stop();
stopWatch.start("processing");
Thread.sleep(5000); // simulated work
stopWatch.stop();
stopWatch.start("finalizing");
Thread.sleep(3000); // simulated work
stopWatch.stop();
System.out.println(stopWatch.prettyPrint());
代码示例来源:origin: stackoverflow.com
final StopWatch stopwatch = new StopWatch();
stopwatch.start();
LOGGER.debug("Starting long calculations: {}", stopwatch);
...
LOGGER.debug("Time after key part of calcuation: {}", stopwatch);
...
LOGGER.debug("Finished calculating {}", stopwatch);
代码示例来源:origin: stackoverflow.com
private void lapWatchAndLog( StopWatch watch, String messageForLap ) {
watch.stop();
LOGGER.info( String.format( "Time: [%s] %s", watch.getTime(), messageForLap ) );
watch.reset();
watch.start();
}
代码示例来源:origin: stackoverflow.com
Set<Class<?>> findAllMessageDrivenClasses() {
final StopWatch sw = new StopWatch();
sw.start();
final Reflections reflections = new Reflections("org.projectx", new TypeAnnotationsScanner());
Set<Class<?>> allMessageDrivens = reflections.getTypesAnnotatedWith(MyMessageDriven.class); // NOTE HERE
sw.stop();
return allMessageDrivens;
}
代码示例来源:origin: NationalSecurityAgency/datawave
protected RunningResource(final Connector cxn) {
super(cxn);
internalTimer = new StopWatch();
internalTimer.start();
}
代码示例来源:origin: stackoverflow.com
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.util.StopWatch;
@Aspect
public class ProfilingAspect {
@Around("methodsToBeProfiled()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
StopWatch sw = new StopWatch(pjp.getSignature().getClass().getSimpleName());
try {
sw.start(pjp.getSignature().getName());
return pjp.proceed();
} finally {
sw.stop();
LogFactory.getLog(pjp.getSignature().getClass()).debug(sw.shortSummary());
}
}
@Pointcut("execution(public * *.*(..))")
public void methodsToBeProfiled(){}
}
代码示例来源:origin: stackoverflow.com
StopWatch stopWatch = new StopWatch();
stopWatch.getTime();
stopWatch.stop();
stopWatch.start();
代码示例来源:origin: com.alexecollins.docker/docker-java-orchestration-core
public PatternMatchingStartupResultCallback(final Logger logger, final List<LogPattern> pendingPatterns, final Id id) {
this.pendingPatterns = Collections.synchronizedList(Lists.newLinkedList(pendingPatterns));
this.id = id;
this.logger = logger;
watch = new StopWatch();
watch.start();
}
代码示例来源:origin: david-schuler/javalanche
public void run() {
try {
stopWatch.start();
Test actualtest = allTests.get(testName);
if (actualtest == null) {
String message = "Test not found in: " + testName
+ "\n All Tests:" + allTests;
System.out.println(message);
logger.warn(message);
System.exit(0);
}
result.addListener(listener);
actualtest.run(result);
} catch (Exception e) {
logger.debug("Cought exception from test " + e
+ " Message " + e.getMessage());
} finally {
stopWatch.stop();
finished = true;
}
}
代码示例来源:origin: stackoverflow.com
StopWatch stopWatch = new StopWatch();
stopWatch.start();
// Do something
stopWatch.stop();
System.out.println(stopWatch.getTotalTimeMillis());
代码示例来源:origin: stackoverflow.com
@Aspect
@Component
public class MyInterceptor {
@Around("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
public Object invoke(ProceedingJoinPoint pjp) throws Throwable {
Object returnValue = null;
final StopWatch stopWatch = new StopWatch();
try {
stopWatch.start();
returnValue = pjp.proceed();
return returnValue;
} catch (Throwable ex) {
throw ex;
} finally {
stopStopwatch(stopWatch);
System.out.println(stopwatch);
}
}
}
代码示例来源:origin: org.carewebframework/org.carewebframework.ui.core
/**
* Executes the target operation with timings.
*/
@Override
public void run() {
watch.start();
ExecutionContext.invoke(page.getId(), () -> {
try {
target.run(ThreadEx.this);
} catch (Throwable e) {
exception = e;
}
});
watch.stop();
ThreadEx.this.done();
}
代码示例来源:origin: stackoverflow.com
ApplicationContext context = new ClassPathXmlApplicationContext("path/to/applicationContext.xml");
JobLauncher launcher=(JobLauncher)context.getBean("launcher");
Job job=(Job)context.getBean("job");
//Get as many beans you want
//Now do the thing you were doing inside test method
StopWatch sw = new StopWatch();
sw.start();
launcher.run(job, jobParameters);
sw.stop();
//initialize the log same way inside main
logger.info(">>> TIME ELAPSED:" + sw.prettyPrint());
代码示例来源:origin: com.atlassian.addon.connect.hercules/hercules-ac
protected ScanResult matchForPatterns(final BufferedReader reader, final Date date)
throws IOException
{
LOGGER.debug("start matching for patterns");
final StopWatch sw = new StopWatch();
sw.start();
final Map<String, PatternMatchSet> results = match(reader, date);
LOGGER.debug("results found: {}", results.size());
return new DefaultScanResult(scanItem, results.values(), Lists.<PropertyScanResult>newArrayList(), sw.getTime());
}
}
代码示例来源:origin: stackoverflow.com
stopwatch.stop();
stopwatch.start();
代码示例来源:origin: zstackio/zstack
public ShellResult run() {
StopWatch watch = new StopWatch();
watch.start();
try {
if (withSudo) {
process.destroy();
watch.stop();
if (!suppressTraceLog && logger.isTraceEnabled()) {
logger.trace(String.format("shell command[%s] costs %sms to finish", command, watch.getTime()));
代码示例来源:origin: com.manydesigns/portofino-pageactions
public Resolution intercept(ExecutionContext context) throws Exception {
logger.debug("Retrieving Stripes objects");
ActionBeanContext actionContext = context.getActionBeanContext();
logger.debug("Retrieving Servlet API objects");
HttpServletRequest request = actionContext.getRequest();
if (request.getDispatcherType() == DispatcherType.REQUEST) {
logger.debug("Starting page response timer");
StopWatch stopWatch = new StopWatch();
// There is no need to stop this timer.
stopWatch.start();
request.setAttribute(RequestAttributes.STOP_WATCH, stopWatch);
}
Resolution resolution = dispatch(actionContext);
return resolution != null ? resolution : context.proceed();
}
代码示例来源:origin: zstackio/zstack
StopWatch watch = new StopWatch();
watch.start();
try {
build();
return ret;
} finally {
watch.stop();
if (logger.isTraceEnabled()) {
if (script != null) {
代码示例来源:origin: david-schuler/javalanche
public static void main(String[] args) throws IOException {
int limit = 1000;
int total = 0;
StopWatch stp = new StopWatch();
stp.start();
File dir = new File("mutation-files/tmp");
dir.mkdir();
for (int i = 0; i < limit; i++) {
Map<String, Set<Integer>> map = getMap();
File tempFile = new File(dir, "test-" + i + ".ser");
if (!tempFile.exists()) {
SerializeIo.serializeToFile(map, tempFile);
} else {
Map<String, Set<Integer>> deserialize = SerializeIo
.get(tempFile);
total += deserialize.size();
}
}
System.out.println("Handling " + limit + " files took "
+ DurationFormatUtils.formatDurationHMS(stp.getTime()));
}
代码示例来源:origin: naver/ngrinder
/**
* Test method for {@link ThreadUtils#sleep(long)}.
*/
@Test
public void testSleep() {
StopWatch watch = new StopWatch();
watch.start();
ThreadUtils.sleep(1000);
watch.stop();
assertThat(watch.getTime()).isGreaterThanOrEqualTo(1000);
assertThat(watch.getTime()).isLessThan(3000);
}
内容来源于网络,如有侵权,请联系作者删除!