org.apache.commons.lang.time.StopWatch.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中org.apache.commons.lang.time.StopWatch.<init>()方法的一些代码示例,展示了StopWatch.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StopWatch.<init>()方法的具体详情如下:
包路径:org.apache.commons.lang.time.StopWatch
类名称:StopWatch
方法名:<init>

StopWatch.<init>介绍

[英]Constructor.
[中]建造师。

代码示例

代码示例来源: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

float time;
protected GHResponse doInBackground( Void... v ){
  StopWatch sw = new StopWatch().start();
  GHRequest req = new GHRequest(fromLat, fromLon, toLat, toLon).
  setAlgorithm(AlgorithmOptions.DIJKSTRA_BI);
  put("instructions", "false");
  GHResponse resp = hopper.route(req);
  time = sw.stop().getSeconds();
  return resp;

代码示例来源: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

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: 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: 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: 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);
}

代码示例来源:origin: com.liferay/com.liferay.portal.search

protected void reindex(Indexer<?> indexer) throws Exception {
  StopWatch stopWatch = new StopWatch();
  stopWatch.start();
  if (_log.isInfoEnabled()) {
    _log.info("Reindexing with " + indexer.getClass() + " started");
  }
  indexer.reindex(new String[] {String.valueOf(_companyId)});
  _usedSearchEngineIds.add(indexer.getSearchEngineId());
  if (_log.isInfoEnabled()) {
    _log.info(
      StringBundler.concat(
        "Reindexing with ", indexer.getClass(), " completed in ",
        stopWatch.getTime() / Time.SECOND, " seconds"));
  }
}

代码示例来源:origin: stackoverflow.com

StopWatch stopwatch = new StopWatch();
stopwatch.start();
... some code...
stopwatch.stop();
long timeTaken = stopWatch.getTime()

代码示例来源:origin: com.atlassian.addon.connect.hercules/hercules-ac

@Override
public ScanResult match(final Date date)
{
  final StopWatch sw = new StopWatch();
  sw.start();
  final Set<PatternMatchSet> matches = Sets.newHashSet();
  final String text = scanItem.getText();
  for (final SisyphusPattern pattern : patternSource)
  {
    final Pattern pat = pattern.getPattern();
    final Matcher m = pat.matcher(text);
    if (m.find())
    {
      final PatternMatchSet match = new PatternMatchSet(pattern);
      match.lineMatched(new LogLine(findMatchLineNumber(text, m.start()), null));
      matches.add(match);
    }
  }
  return new DefaultScanResult(scanItem, matches, Lists.<PropertyScanResult>newArrayList(), sw.getTime());
}

代码示例来源:origin: stackoverflow.com

import java.util.Arrays;

public class TestStopWatch {

  public void measureTime(){

  StopWatch stopWatch = new StopWatch();

  double startTime = stopWatch.start(); //trying to call the start method in the previous class

  //code to create and sort array

    double endTime = stopWatch.stop(); //stop method in previous class

  System.out.println(getElapsedTime(startTime,endTime)); //call getElapsedtime and print

  }
}

相关文章