Examples of StopWatch


Examples of org.sleuthkit.autopsy.coreutils.StopWatch

                i++;
            }

            progressGroup.start();

            final StopWatch stopWatch = new StopWatch();
            stopWatch.start();
            try {
                progressGroup.setDisplayName(displayName);

                int keywordsSearched = 0;

                for (Keyword keywordQuery : keywords) {
                    if (this.isCancelled()) {
                        logger.log(Level.INFO, "Cancel detected, bailing before new keyword processed: {0}", keywordQuery.getQuery()); //NON-NLS
                        return null;
                    }

                    final String queryStr = keywordQuery.getQuery();
                    final KeywordList list = keywordToList.get(queryStr);

                    //new subProgress will be active after the initial query
                    //when we know number of hits to start() with
                    if (keywordsSearched > 0) {
                        subProgresses[keywordsSearched - 1].finish();
                    }

                    KeywordSearchQuery keywordSearchQuery = null;

                    boolean isRegex = !keywordQuery.isLiteral();
                    if (isRegex) {
                        keywordSearchQuery = new TermComponentQuery(list, keywordQuery);
                    } else {
                        keywordSearchQuery = new LuceneQuery(list, keywordQuery);
                        keywordSearchQuery.escape();
                    }

                    // Filtering
                    //limit search to currently ingested data sources
                    //set up a filter with 1 or more image ids OR'ed
                    final KeywordQueryFilter dataSourceFilter = new KeywordQueryFilter(KeywordQueryFilter.FilterType.DATA_SOURCE, job.getDataSourceId());
                    keywordSearchQuery.addFilter(dataSourceFilter);

                    QueryResults queryResults;

                    // Do the actual search
                    try {
                        queryResults = keywordSearchQuery.performQuery();
                    } catch (NoOpenCoreException ex) {
                        logger.log(Level.WARNING, "Error performing query: " + keywordQuery.getQuery(), ex); //NON-NLS
                        //no reason to continue with next query if recovery failed
                        //or wait for recovery to kick in and run again later
                        //likely case has closed and threads are being interrupted
                        return null;
                    } catch (CancellationException e) {
                        logger.log(Level.INFO, "Cancel detected, bailing during keyword query: {0}", keywordQuery.getQuery()); //NON-NLS
                        return null;
                    } catch (Exception e) {
                        logger.log(Level.WARNING, "Error performing query: " + keywordQuery.getQuery(), e); //NON-NLS
                        continue;
                    }

                    // calculate new results by substracting results already obtained in this ingest
                    // this creates a map of each keyword to the list of unique files that have that hit.
                    QueryResults newResults = filterResults(queryResults);

                    if (!newResults.getKeywords().isEmpty()) {

                        // Write results to BB

                        //new artifacts created, to report to listeners
                        Collection<BlackboardArtifact> newArtifacts = new ArrayList<>();

                        //scale progress bar more more granular, per result sub-progress, within per keyword
                        int totalUnits = newResults.getKeywords().size();
                        subProgresses[keywordsSearched].start(totalUnits);
                        int unitProgress = 0;
                        String queryDisplayStr = keywordQuery.getQuery();
                        if (queryDisplayStr.length() > 50) {
                            queryDisplayStr = queryDisplayStr.substring(0, 49) + "...";
                        }
                        subProgresses[keywordsSearched].progress(list.getName() + ": " + queryDisplayStr, unitProgress);
       
                        // Create blackboard artifacts               
                        newArtifacts = newResults.writeAllHitsToBlackBoard(null, subProgresses[keywordsSearched], this, list.getIngestMessages());
                       
                    } //if has results

                    //reset the status text before it goes away
                    subProgresses[keywordsSearched].progress("");

                    ++keywordsSearched;

                } //for each keyword

            } //end try block
            catch (Exception ex) {
                logger.log(Level.WARNING, "searcher exception occurred", ex); //NON-NLS
            } finally {
                try {
                    finalizeSearcher();
                    stopWatch.stop();                  
                   
                    logger.log(Level.INFO, "Searcher took to run: {0} secs.", stopWatch.getElapsedTimeSecs()); //NON-NLS
                } finally {
                    // In case a thread is waiting on this worker to be done
                    job.searchNotify();
                }
            }
View Full Code Here

Examples of org.sonar.core.profiling.StopWatch

  }

  @Override
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (method.getName().startsWith("execute")) {
      StopWatch watch = PROFILING.start();
      Object result = null;
      try {
        result = InvocationUtils.invokeQuietly(statement, method, args);
      } finally {
        PROFILING.stop(watch, (String) args[0]);
View Full Code Here

Examples of org.springframework.util.StopWatch

  public ThreadPoolTaskExecutor(int poolSize, int maxPoolSize, int keepAliveTime) {
    threadPool = new ThreadPoolExecutor(poolSize, maxPoolSize, keepAliveTime, TimeUnit.SECONDS, queue);
  }

  public void runTask(Runnable task) {
    StopWatch watch = null;
    if (log.isDebug()) {
      watch = new StopWatch();
      watch.start();
    }   
    threadPool.execute(task);
   
    if (log.isDebug()) watch.stop();
    if (log.isDebug()) log.debug("Current size of queue is: "+queue.size()+". Running last task took (ms): "+watch.getTotalTimeMillis());
  }
View Full Code Here

Examples of org.trifort.rootbeer.runtime.util.Stopwatch

    usingHandles = false;
    nativeContext = allocateNativeContext();
    cacheConfig = CacheConfig.PREFER_NONE;
   
    stats = new StatsRow();
    writeBlocksStopwatch = new Stopwatch();
    runStopwatch = new Stopwatch();
    runOnGpuStopwatch = new Stopwatch();
    readBlocksStopwatch = new Stopwatch();
  }
View Full Code Here

Examples of org.xmlBlaster.util.StopWatch

      String subQos = subQosW.toXml();

      manyClients = new Client[numClients];

      log.info("Setting up " + numClients + " subscriber clients ...");
      stopWatch = new StopWatch();
      for (int ii=0; ii<numClients; ii++) {
         Client sub = new Client();
         sub.loginName = "Joe-" + ii;

         try {
View Full Code Here

Examples of penny.util.StopWatch

    void runInput(InputStream in, AbstractDownload d) throws IOException {
        Logger.getLogger(Downloader.class.getName()).entering(Downloader.class.getName(), "runInput");
        if (d.getStatus() == DownloadStatus.DOWNLOADING) {
            int read;
            StopWatch bufferWatch = new StopWatch();
            ByteArrayList chunk = new ByteArrayList();
            byte inputBuffer[] = new byte[128];
            byte outputBuffer[] = new byte[128];
            int multiplier = 1;
            int growCount = 0;
            int shrinkCount = 0;
            int changeOn = 5;
            int accelerateOn = 10;
            bufferWatch.start();
            read = in.read(inputBuffer);
            d.initDownloadTime();
            while (read != -1 && d.getStatus() == DownloadStatus.DOWNLOADING) {
                assert (multiplier > 0);
                for (int i = 0; i < multiplier && read != -1 && d.getStatus() == DownloadStatus.DOWNLOADING; i++) {
                    chunk.addElements(chunk.size(), inputBuffer, 0, read);
                    read = in.read(inputBuffer);
                }
                d.updateDownloadTime();
                if (chunk.size() > outputBuffer.length) {
                    outputBuffer = new byte[chunk.size()];
                }
                processor.doChunck(chunk.size(), chunk.toByteArray(outputBuffer));
                d.setDownloaded(d.getDownloaded() + chunk.size());
                chunk.clear();
                bufferWatch.add();
                //System.out.print(bufferWatch);
                long maxTime = getdSettings().getBufferTime() * 1000000;
                if (bufferWatch.getTime() < maxTime) {
                    growCount++;
                    shrinkCount = 0;
                    if (growCount >= accelerateOn) {
                        multiplier += growCount;
                    } else if (growCount >= changeOn) {
                        multiplier++;
                    }
                    //System.out.println(" grow " + multiplier);
                } else if (multiplier > 1) {
                    shrinkCount++;
                    growCount = 0;
                    if (shrinkCount >= accelerateOn && multiplier - shrinkCount > 1) {
                        multiplier -= shrinkCount;
                    } else if (shrinkCount >= changeOn) {
                        multiplier--;
                    }
                    //System.out.println(" shrink " + multiplier);
                }
                bufferWatch.restart();
            }
        }
        Logger.getLogger(Downloader.class.getName()).exiting(Downloader.class.getName(), "runInput");
    }
View Full Code Here

Examples of railo.runtime.timer.Stopwatch

 
 
  private void typeColumns(DatabaseMetaData metaData) throws PageException, SQLException {
    required("table",table);
   
    Stopwatch stopwatch=new Stopwatch(Stopwatch.UNIT_NANO);
    stopwatch.start();

    table=setCase(metaData, table);
    pattern=setCase(metaData, pattern);
    if(StringUtil.isEmpty(pattern,true)) pattern=null;
    String schema=null;
    int index=table.indexOf('.');
    if(index>0) {
      schema=table.substring(0,index);
      table=table.substring(index+1);
    }
    checkTable(metaData);
   
        Query qry = new QueryImpl(
            metaData.getColumns(dbname, schema, table, pattern),
            "query",
            pageContext.getTimeZone());
       
    int len=qry.getRecordcount();

    if(qry.getColumn(COLUMN_DEF,null) != null)
      qry.rename(COLUMN_DEF,COLUMN_DEFAULT_VALUE);
    else if(qry.getColumn(COLUMN_DEFAULT,null) != null)
      qry.rename(COLUMN_DEFAULT,COLUMN_DEFAULT_VALUE);
   
    // make sure decimal digits exists
    QueryColumn col = qry.getColumn(DECIMAL_DIGITS,null);
    if(col==null){
      Array arr=new ArrayImpl();
      for(int i=1;i<=len;i++) {
        arr.append(railo.runtime.op.Constants.DOUBLE_ZERO);
      }
      qry.addColumn(DECIMAL_DIGITS, arr);
    }
   
   
    // add is primary
    Map primaries = new HashMap();
    String tblName;
    Array isPrimary=new ArrayImpl();
    Set set;
    Object o;
    for(int i=1;i<=len;i++) {
     
      // decimal digits
      o=qry.getAt(DECIMAL_DIGITS, i,null);
      if(o==null)qry.setAtEL(DECIMAL_DIGITS, i,railo.runtime.op.Constants.DOUBLE_ZERO);
     
      set=(Set) primaries.get(tblName=(String) qry.getAt(TABLE_NAME, i));
      if(set==null) {
        set=toSet(metaData.getPrimaryKeys(dbname, null, tblName),true,"COLUMN_NAME");
        primaries.put(tblName,set);
      }
      isPrimary.append(set.contains(qry.getAt(COLUMN_NAME, i))?"YES":"NO");
    }
    qry.addColumn(IS_PRIMARYKEY, isPrimary);
   
    // add is foreignkey
    Map foreigns = new HashMap();
    Array isForeign=new ArrayImpl();
    Array refPrim=new ArrayImpl();
    Array refPrimTbl=new ArrayImpl();
    //Map map,inner;
    Map<String, Map<String, SVArray>> map;
    Map<String, SVArray> inner;
    for(int i=1;i<=len;i++) {
      map=(Map) foreigns.get(tblName=(String) qry.getAt(TABLE_NAME, i));
      if(map==null) {
        map=toMap(
            metaData.getImportedKeys(dbname, schema, table),
            true,
            "FKCOLUMN_NAME",
            new String[]{"PKCOLUMN_NAME","PKTABLE_NAME"});
        foreigns.put(tblName, map);
      }
      inner = map.get(qry.getAt(COLUMN_NAME, i));
      if(inner!=null) {
        isForeign.append("YES");
        refPrim.append(inner.get("PKCOLUMN_NAME"));
        refPrimTbl.append(inner.get("PKTABLE_NAME"));
      }
      else {
        isForeign.append("NO");
        refPrim.append("N/A");
        refPrimTbl.append("N/A");     
      }
    }
    qry.addColumn(IS_FOREIGNKEY, isForeign);
    qry.addColumn(REFERENCED_PRIMARYKEY, refPrim);
    qry.addColumn(REFERENCED_PRIMARYKEY_TABLE, refPrimTbl);
   
   
    qry.setExecutionTime(stopwatch.time());
       
       
    pageContext.setVariable(name, qry);
  }
View Full Code Here

Examples of ro.isdc.wro.util.StopWatch

        // nothing to do
    }

    @Override
    public WroModel create() {
        final StopWatch stopWatch = new StopWatch("Create Wro Model using Geonetwork");
        try {
            stopWatch.start("createModel");
            final String sourcesXmlFile = getSourcesXmlFile();

            if (isMavenBuild() && _geonetworkRootDirectory.isEmpty()) {
                _geonetworkRootDirectory = findGeonetworkRootDirectory(sourcesXmlFile);
            }
            FileInputStream sourcesInputStream = null;
            try {
                sourcesInputStream = new FileInputStream(sourcesXmlFile);
                final WroModel model = createModel(sourcesXmlFile, sourcesInputStream);
                logModel(model);
                return model;
            } finally {
                if (sourcesInputStream != null) {
                    IOUtils.closeQuietly(sourcesInputStream);
                }
            }

        } catch (RuntimeException e) {
            throw e;
        } catch (Error e) {
            throw e;
        } catch (Throwable e) {
            throw new RuntimeException(e);
        } finally {
            stopWatch.stop();
            LOG.info(stopWatch.prettyPrint());
        }
    }
View Full Code Here

Examples of turbojpeg.utils.StopWatch

    final Pointer<CLong> lPointerToCLong = Pointer.allocateCLong();

    lPointerToCLong.setCLong(lCompressedImage.capacity());

    int ec = 0;
    final StopWatch lCompressionTime = StopWatch.start();
    final int lNumberOfRepeats = 1000;
    for (int i = 0; i < lNumberOfRepeats; i++)
    {
      ec = TurbojpegLibrary.tjCompress2(lPointerToCompressor,
                                        Pointer.pointerToBytes(lDmImage),
                                        512,
                                        512,
                                        1024,
                                        (int) TJPF.TJPF_GRAY.value,
                                        lPointerToPointer,
                                        lPointerToCLong,
                                        (int) TJSAMP.TJSAMP_GRAY.value,
                                        90,
                                        TurbojpegLibrary.TJFLAG_NOREALLOC | TurbojpegLibrary.TJFLAG_FORCESSE3
                                            | TurbojpegLibrary.TJFLAG_FASTDCT);
    }
    final long lCompressionElapsedTime = lCompressionTime.time(TimeUnit.MILLISECONDS);
    System.out.format("Compression: %d ms \n",
                      lCompressionElapsedTime / lNumberOfRepeats);

    System.out.println(ec);

    lCompressedImage.limit((int) lPointerToCLong.getCLong());

    final double ratio = (double) lCompressedImage.limit() / lDmImage.limit();

    System.out.format("Compression ratio: %g  \n", ratio);

    final ByteBuffer lDmImageDecompressed = ByteBuffer.allocateDirect(lDmImage.limit())
                                                      .order(ByteOrder.nativeOrder());

    final Pointer<?> lPointerToDecompressor = TurbojpegLibrary.tjInitDecompress();

    final StopWatch lDecompressionTime = StopWatch.start();
    final int ed = TurbojpegLibrary.tjDecompress2(lPointerToDecompressor,
                                                  Pointer.pointerToBytes(lCompressedImage),
                                                  lCompressedImage.limit(),
                                                  Pointer.pointerToBytes(lDmImageDecompressed),
                                                  512,
                                                  512,
                                                  1024,
                                                  (int) TJPF.TJPF_GRAY.value,
                                                  TurbojpegLibrary.TJFLAG_ACCURATEDCT);
    final long lDecompressionElapsedTime = lDecompressionTime.time(TimeUnit.MILLISECONDS);
    System.out.format("Decompression: %d ms \n",
                      lDecompressionElapsedTime);

    System.out.println(ed);
View Full Code Here

Examples of util.StopWatch

  static void testJava() throws Exception {

    log.info("### JAVA ###");

    long nanos;
    final StopWatch timer = new StopWatch();

    timer.start();
    for (int k = 0; k < COUNT; k++) {
      // baseline
    }
    timer.stop();
    nanos = timer.nanoTime() / COUNT;
    log.info("baseline nanos={}", nanos);

    timer.start();
    for (int k = 0; k < COUNT; k++) {
      // small array
      final byte[] array = new byte[128];
    }
    timer.stop();
    nanos = timer.nanoTime() / COUNT;
    log.info("make array 123; nanos={}", nanos);

    timer.start();
    for (int k = 0; k < COUNT; k++) {
      // medium array
      final byte[] array = new byte[1024];
    }
    timer.stop();
    nanos = timer.nanoTime() / COUNT;
    log.info("make array 1024; nanos={}", nanos);

    final int[] arrayInt = new int[SIZE];
    timer.start();
    for (int k = 0; k < COUNT; k++) {
      Arrays.fill(arrayInt, 1235678);
    }
    timer.stop();
    nanos = timer.nanoTime() / COUNT / SIZE;
    log.info("fill array; nanos={}", nanos);

    //

    final Integer[] array = new Integer[1024];
    timer.start();
    for (int k = 0; k < COUNT; k++) {
      for (final Integer i : array) {
        // iterate array
        final Integer x = i;
      }
    }
    timer.stop();
    nanos = timer.nanoTime() / COUNT / 1024;
    log.info("iterate array; nanos={}", nanos);

    // SET
    final Set<Integer> set = new HashSet<Integer>();
    for (int k = 0; k < 1024; k++) {
      set.add(k);
    }
    //
    timer.start();
    for (int k = 0; k < COUNT; k++) {
      for (final Integer i : set) {
        // iterate set
        final Integer x = i;
      }
    }
    timer.stop();
    nanos = timer.nanoTime() / COUNT / 1024;
    log.info("iterate set; nanos={}", nanos);
    //
    timer.start();
    for (int k = 0; k < COUNT; k++) {
      final Object[] x = set.toArray();
    }
    timer.stop();
    nanos = timer.nanoTime() / COUNT;
    log.info("set to array; nanos={}", nanos);

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.