当前位置: 首页>>代码示例>>Java>>正文


Java Stopwatch.reset方法代码示例

本文整理汇总了Java中com.google.common.base.Stopwatch.reset方法的典型用法代码示例。如果您正苦于以下问题:Java Stopwatch.reset方法的具体用法?Java Stopwatch.reset怎么用?Java Stopwatch.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.base.Stopwatch的用法示例。


在下文中一共展示了Stopwatch.reset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: timeThen

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
public static void timeThen(Runnable r, Consumer<Long> then) {
  Stopwatch s = getShareStopwatch();
  s.reset();
  s.start();
  r.run();
  s.stop();
  if (then != null) {
    then.accept(s.elapsed(TimeUnit.MILLISECONDS));
  }
}
 
开发者ID:XDean,项目名称:Java-EX,代码行数:11,代码来源:TimingUtil.java

示例2: seriesTimeThen

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
/**
 * @param uniqueKey unique key
 * @param r the task
 * @param then (this time, total time) -&#62; {...}
 */
public static void seriesTimeThen(Object uniqueKey, Runnable r, BiConsumer<Long, Long> then) {
  Stopwatch total = CacheUtil.cache(TimingUtil.class, uniqueKey, () -> Stopwatch.createUnstarted());
  Stopwatch temp = getShareStopwatch();
  temp.reset();
  temp.start();
  total.start();
  r.run();
  temp.stop();
  total.stop();
  if (then != null) {
    then.accept(temp.elapsed(TimeUnit.MILLISECONDS), total.elapsed(TimeUnit.MILLISECONDS));
  }
}
 
开发者ID:XDean,项目名称:Java-EX,代码行数:19,代码来源:TimingUtil.java

示例3: run

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
public Optional<String> run() throws IOException {
    Stopwatch stopwatch = Stopwatch.createStarted();
    log.info("Start generating {}", outputZone);
    new File(outputZone).mkdirs();

    List<String> profileShapeFiles = newArrayList();

    for (ClassInfo clazz : shapefiles()) {
        log.info("Converting {}", clazz.getSimpleName());
        TomtomShapefile shapefile = (TomtomShapefile) injector.getInstance(clazz.load());
        if (shapefile.getFile().exists()) {
            shapefile.serialize(outputZone);
            profileShapeFiles.add(shapefile.getOutputFile());
        } else {
            log.info("No input file found");
        }
    }

    if (profileShapeFiles.isEmpty()) {
        return empty();
    }

    osmMerger.merge(profileShapeFiles, outputZone + OSM_SUFFIX);
    log.info("Done generating {} in {}", outputZone + OSM_SUFFIX, stopwatch);

    stopwatch.reset();
    stopwatch.start();

    splitter.run();
    log.info("Done splitting {} in {}", outputZone, stopwatch);

    return of(outputZone + OSM_SUFFIX);
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:34,代码来源:Tomtom2Osm.java

示例4: readPage

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
public void readPage(PageHeader pageHeader, int compressedSize, int uncompressedSize, ArrowBuf dest) throws IOException {
  Stopwatch timer = Stopwatch.createUnstarted();
  long timeToRead;
  long start = inputStream.getPos();
  if (parentColumnReader.columnChunkMetaData.getCodec() == CompressionCodecName.UNCOMPRESSED) {
    timer.start();
    dataReader.loadPage(dest, compressedSize);
    timeToRead = timer.elapsed(TimeUnit.MICROSECONDS);
    this.updateStats(pageHeader, "Page Read", start, timeToRead, compressedSize, uncompressedSize);
  } else {
    final ArrowBuf compressedData = allocateTemporaryBuffer(compressedSize);
    try {
      timer.start();
      dataReader.loadPage(compressedData, compressedSize);
      timeToRead = timer.elapsed(TimeUnit.MICROSECONDS);
      timer.reset();
      this.updateStats(pageHeader, "Page Read", start, timeToRead, compressedSize, compressedSize);
      start = inputStream.getPos();
      timer.start();
      codecFactory.getDecompressor(parentColumnReader.columnChunkMetaData
        .getCodec()).decompress(compressedData.nioBuffer(0, compressedSize), compressedSize,
        dest.nioBuffer(0, uncompressedSize), uncompressedSize);
      timeToRead = timer.elapsed(TimeUnit.MICROSECONDS);
      this.updateStats(pageHeader, "Decompress", start, timeToRead, compressedSize, uncompressedSize);
    } finally {
      compressedData.release();
    }
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:30,代码来源:PageReader.java

示例5: submitQuery

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
public int submitQuery(DrillClient client, String plan, String type, String format, int width) throws Exception {

    PrintingResultsListener listener;

    String[] queries;
    QueryType queryType;
    type = type.toLowerCase();
    switch (type) {
      case "sql":
        queryType = QueryType.SQL;
        queries = plan.trim().split(";");
        break;
      case "logical":
        queryType = QueryType.LOGICAL;
        queries = new String[]{ plan };
        break;
      case "physical":
        queryType = QueryType.PHYSICAL;
        queries = new String[]{ plan };
        break;
      default:
        System.out.println("Invalid query type: " + type);
        return -1;
    }

    Format outputFormat;
    format = format.toLowerCase();
    switch (format) {
      case "csv":
        outputFormat = Format.CSV;
        break;
      case "tsv":
        outputFormat = Format.TSV;
        break;
      case "table":
        outputFormat = Format.TABLE;
        break;
      default:
        System.out.println("Invalid format type: " + format);
        return -1;
    }
    Stopwatch watch = new Stopwatch();
    for (String query : queries) {
      listener = new PrintingResultsListener(client.getConfig(), outputFormat, width);
      watch.start();
      client.runQuery(queryType, query, listener);
      int rows = listener.await();
      System.out.println(String.format("%d record%s selected (%f seconds)", rows, rows > 1 ? "s" : "", (float) watch.elapsed(TimeUnit.MILLISECONDS) / (float) 1000));
      if (query != queries[queries.length - 1]) {
        System.out.println();
      }
      watch.stop();
      watch.reset();
    }
    return 0;

  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:58,代码来源:QuerySubmitter.java

示例6: submitQuery

import com.google.common.base.Stopwatch; //导入方法依赖的package包/类
public int submitQuery(DremioClient client, String plan, String type, String format, int width) throws Exception {

    String[] queries;
    QueryType queryType;
    type = type.toLowerCase();
    switch (type) {
      case "sql":
        queryType = QueryType.SQL;
        queries = plan.trim().split(";");
        break;
      case "logical":
        queryType = QueryType.LOGICAL;
        queries = new String[]{ plan };
        break;
      case "physical":
        queryType = QueryType.PHYSICAL;
        queries = new String[]{ plan };
        break;
      default:
        System.out.println("Invalid query type: " + type);
        return -1;
    }

    Format outputFormat;
    format = format.toLowerCase();
    switch (format) {
      case "csv":
        outputFormat = Format.CSV;
        break;
      case "tsv":
        outputFormat = Format.TSV;
        break;
      case "table":
        outputFormat = Format.TABLE;
        break;
      default:
        System.out.println("Invalid format type: " + format);
        return -1;
    }
    Stopwatch watch = Stopwatch.createUnstarted();
    for (String query : queries) {
      AwaitableUserResultsListener listener =
          new AwaitableUserResultsListener(new PrintingResultsListener(client.getConfig(), outputFormat, width));
      watch.start();
      client.runQuery(queryType, query, listener);
      int rows = listener.await();
      System.out.println(String.format("%d record%s selected (%f seconds)", rows, rows > 1 ? "s" : "", (float) watch.elapsed(TimeUnit.MILLISECONDS) / (float) 1000));
      if (query != queries[queries.length - 1]) {
        System.out.println();
      }
      watch.stop();
      watch.reset();
    }
    return 0;

  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:57,代码来源:QuerySubmitter.java


注:本文中的com.google.common.base.Stopwatch.reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。