Examples of StopWatch


Examples of Framework.StopWatch

        weird.setValue( "XXX" );
        weird.setValue("ABC");
        weird.setValue( (String)null);
        weird.setValue("CCC");
        weird.setValue((TextData)null);
        StopWatch sw = new StopWatch();
        sw.fire();
        for (int i = 1; i <= 10000; i++) {

            //
            //   with textdata format and 1 parameter
            format = new TextData("my name is %1");
            text.replaceParameters(format, new TextData("Fred"));
            //
            //   with textdata format and 2 parameters
            format = new TextData("my name is %1 %2");
            text.replaceParameters(format, new TextData("Fred"), new TextData("Jones"));
            //
            //   with textdata format and 3 parameters
            format = new TextData("my name is %1 %2, age: %3");
            text.replaceParameters(format, new TextData("Fred"), new TextData("Jones"), new IntegerData(35));
            //
            //   with textdata format and 4 parameters
            format = new TextData("my name is %1 %2, age: %3, weight %4");
            text.replaceParameters(format, new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85));
            //
            //   with textdata format and 5 parameters
            format = new TextData("my name is %1 %2, age: %3, weight %4, married %5");
            text.replaceParameters(format, new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85), new BooleanData(true, BooleanData.qq_Resolver.cVALUE));
            //
            //   with textdata format and 6 parameters
            format = new TextData("my name is %1 %2, age: %3, weight %4, married %5, born %6");
            text.replaceParameters(format, new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85), new BooleanData(true, BooleanData.qq_Resolver.cVALUE), new DateTimeData(new TextData("01-Jan-1960"), DateTimeData.qq_Resolver.cVALUE));
            //
            //   with textdata format and 7 parameters
            format = new TextData("my name is %1 %2, age: %3, weight %4, married %5, born %6, ratio %7");
            text.replaceParameters(format, new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85), new BooleanData(true, BooleanData.qq_Resolver.cVALUE), new DateTimeData(new TextData("01-Jan-1960"), DateTimeData.qq_Resolver.cVALUE), new DoubleData(3.4));
            //
            //   with textdata format and 8 parameters
            format = new TextData("my name is %1 %2, age: %3, weight %4, married %5, born %6, ratio %7, income %8");
            text.replaceParameters(format, new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85), new BooleanData(true, BooleanData.qq_Resolver.cVALUE), new DateTimeData(new TextData("01-Jan-1960"), DateTimeData.qq_Resolver.cVALUE), new DoubleData(3.4), new DecimalData(50010.35));
            //
            //   with textdata format and 9 parameters
            format = new TextData("my name is %1 %2, age: %3, weight %4, married %5, born %6, ratio %7, income %8, happy %9");
            text.replaceParameters(format, new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85), new BooleanData(true, BooleanData.qq_Resolver.cVALUE), new DateTimeData(new TextData("01-Jan-1960"), DateTimeData.qq_Resolver.cVALUE), new DoubleData(3.4), new DecimalData(50010.35), new BooleanData(true, BooleanData.qq_Resolver.cVALUE));

            //
            //   with string format and 1 parameter
            text.replaceParameters("my name is %1", new TextData("Fred"));
            //
            //   with string format and 2 parameters
            text.replaceParameters("my name is %1 %2", new TextData("Fred"), new TextData("Jones"));
            //
            //   with string format and 3 parameters
            text.replaceParameters("my name is %1 %2, age: %3", new TextData("Fred"), new TextData("Jones"), new IntegerData(35));
            //
            //   with string format and 4 parameters
            text.replaceParameters("my name is %1 %2, age: %3, weight %4", new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85));
            //
            //   with string format and 5 parameters
            text.replaceParameters("my name is %1 %2, age: %3, weight %4, married %5", new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85), new BooleanData(true, BooleanData.qq_Resolver.cVALUE));
            //
            //   with string format and 6 parameters
            text.replaceParameters("my name is %1 %2, age: %3, weight %4, married %5, born %6", new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85), new BooleanData(true, BooleanData.qq_Resolver.cVALUE), new DateTimeData(new TextData("01-Jan-1960"), DateTimeData.qq_Resolver.cVALUE));
            //
            //   with string format and 7 parameters
            text.replaceParameters("my name is %1 %2, age: %3, weight %4, married %5, born %6, ratio %7", new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85), new BooleanData(true, BooleanData.qq_Resolver.cVALUE), new DateTimeData(new TextData("01-Jan-1960"), DateTimeData.qq_Resolver.cVALUE), new DoubleData(3.4));
            //
            //   with string format and 8 parameters
            text.replaceParameters("my name is %1 %2, age: %3, weight %4, married %5, born %6, ratio %7, income %8", new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85), new BooleanData(true, BooleanData.qq_Resolver.cVALUE), new DateTimeData(new TextData("01-Jan-1960"), DateTimeData.qq_Resolver.cVALUE), new DoubleData(3.4), new DecimalData(50010.35));
            //
            //   with string format and 9 parameters
            text.replaceParameters("my name is %1 %2, age: %3, weight %4, married %5, born %6, ratio %7, income %8, happy %9", new TextData("Fred"), new TextData("Jones"), new IntegerData(35), new IntegerData(85), new BooleanData(true, BooleanData.qq_Resolver.cVALUE), new DateTimeData(new TextData("01-Jan-1960"), DateTimeData.qq_Resolver.cVALUE), new DoubleData(3.4), new DecimalData(50010.35), new BooleanData(true, BooleanData.qq_Resolver.cVALUE));

        }

        int time = (int)sw.split();
        Logger.getLogger("task.part.logmgr").info( Integer.toString(time));
    }
View Full Code Here

Examples of com.barchart.udt.util.StopWatch

  }

  static void testJava() throws Exception {

    long nanos;
    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
      byte[] array = new byte[128];
    }
    timer.stop();
    nanos = timer.nanoTime() / COUNT;
    log.info("make small array; nanos={}", nanos);

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

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

    //

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

    // SET
    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 (Integer i : set) {
        // iterate set
        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++) {
      Object[] x = set.toArray();
    }
    timer.stop();
    nanos = timer.nanoTime() / COUNT;
    log.info("set to array; nanos={}", nanos);

  }
View Full Code Here

Examples of com.bj58.spat.gaea.server.contract.context.StopWatch

    }
  }

  @Override
  public void filter(GaeaContext context) throws Exception {
    StopWatch sw = context.getStopWatch();
    Collection<PerformanceCounter> pcList = sw.getMapCounter().values();
    for(PerformanceCounter pc : pcList) {
      if(pc.getExecuteTime() > minRecordTime) {
        StringBuilder sbMsg = new StringBuilder();
        sbMsg.append(serviceName);
        sbMsg.append("--");
        sbMsg.append(pc.getKey());
        sbMsg.append("--time: ");
        sbMsg.append(pc.getExecuteTime());
       
        sbMsg.append(" [fromIP: ");
        sbMsg.append(sw.getFromIP());
        sbMsg.append(";localIP: ");
        sbMsg.append(sw.getLocalIP()+"]");
       
        udpClient.send(sbMsg.toString());
      }
    }
  }
View Full Code Here

Examples of com.cetsoft.caudit.stopwatch.Stopwatch

     */
    public Audit create(AuditType type, int auditId) {
      String auditName = mapper.getAuditName(auditId);
      switch (type) {
      case BASIC_STOPWATCH:
        return new Stopwatch(auditId, auditName);
      case COUNTING_STOPWATCH:
        return new CountingStopwatch(auditId, auditName);
      case LONG_QUANTITY:
        return new LongQuantity(auditId, auditName);
      case DOUBLE_QUANTITY:
View Full Code Here

Examples of com.dbxml.util.Stopwatch

            case 2:
               if ( info instanceof HasDocWrapper ) {
                  e.consume();
                  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                  Stopwatch sw = new Stopwatch("Document Retrieval", true);
                  DocWrapper dw = ((HasDocWrapper)info).getDocWrapper();
                  sw.stop();
                  admin.setStatus(sw.toString());
                  admin.editDocument(dw);
                  setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
               }
               break;
         }
View Full Code Here

Examples of com.discoverydns.dnsapiclient.internal.util.Stopwatch

  public Object intercept(final Object command,
      final CommandMetaData commandMetaData,
      final CommandInterceptorChain commandInterceptorChain)
      throws Throwable {
    Throwable exception = null;
    final Stopwatch stopwatch = new Stopwatch();
    stopwatch.start();
    Object response = null;
    try {
      response = commandInterceptorChain.proceed();
    } catch (final Throwable t) {
      exception = t;
    }
    stopwatch.stop();
    commandMetaData.put(COMMAND_TIME_MS,
        new Double(stopwatch.elapsedTimeMsDecimal()));
    if (exception != null) {
      throw exception;
    }
    return response;
  }
View Full Code Here

Examples of com.ecyrd.speed4j.StopWatch

  @Override
  public Map<MailAddress, DeliveryReturnCode> deliver(MailEnvelope env, final String deliveryId)
      throws IOException
  {
    StopWatch stopWatch = Activator.getDefault().getStopWatch();
    Message message;

    try {
      MimeParser parser = new MimeParser();
      parser.parse(env.getMessageInputStream());
      message = parser.getMessage();
    } catch (MimeParserException mpe) {
      logger.error("DID" + deliveryId + ": unable to parse message: ", mpe);
      throw new DeliveryException("Unable to parse message: " + mpe.getMessage());
    } catch (IOException ioe) {
      logger.error("DID" + deliveryId + ": unable to read message stream: ", ioe);
      throw new DeliveryException("Unable to read message stream: " + ioe.getMessage());
    }

    message.setSize((long) env.getSize()); // update message size

    FilterProcessor<Message> processor = new FilterProcessor<Message>();
    //processor.add(new NotificationMailFilter());
    processor.add(new SpamMailFilter());
    processor.add(new DefaultMailFilter());
    message = processor.doFilter(message);

    logEnvelope(env, message, deliveryId);

    Map<MailAddress, DeliveryReturnCode> replies = new HashMap<MailAddress, DeliveryReturnCode>();
    // Deliver to each recipient
    for (MailAddress recipient : env.getRecipients())
    {
      DeliveryReturnCode reply = DeliveryReturnCode.TEMPORARY_FAILURE; // default LMTP reply
      DeliveryAction deliveryAction = DeliveryAction.DELIVER; // default delivery action

      Mailbox mailbox = new Mailbox(recipient.toString());
      String logMsg = new StringBuilder(" ").append(mailbox.getId())
                .append(" DID").append(deliveryId).toString();

      try {
        switch (deliveryAction) {
        case DELIVER:
          try {
            // generate new UUID
            UUID messageId = new MessageIdBuilder().build();

            // store message
            messageDAO.put(mailbox, messageId, message, env.getMessageInputStream());

            // successfully delivered
            stopWatch.stop("DELIVERY.success", logMsg);
            reply = DeliveryReturnCode.OK;
          } catch (OverQuotaException e) {
            // account is over quota, reject
            stopWatch.stop("DELIVERY.reject_overQuota", logMsg + " over quota");
            reply = DeliveryReturnCode.OVER_QUOTA;
          } catch (IOException e) {
            // delivery error, defer
            stopWatch.stop("DELIVERY.defer", logMsg);
            logger.error("DID" + deliveryId + ": delivery error: ", e);
            reply = DeliveryReturnCode.TEMPORARY_FAILURE;
          }
          break;
        case DISCARD:
          // Local delivery is disabled.
          stopWatch.stop("DELIVERY.discard", logMsg);
          reply = DeliveryReturnCode.OK;
          break;
        case DEFER:
          // Delivery to mailbox skipped. Let MTA retry again later.
          stopWatch.stop("DELIVERY.defer", logMsg);
          reply = DeliveryReturnCode.TEMPORARY_FAILURE;
          break;
        case REJECT:
          // Reject delivery. Account or mailbox not found.
          stopWatch.stop("DELIVERY.reject_nonExistent", logMsg + " unknown mailbox");
          reply = DeliveryReturnCode.NO_SUCH_USER;
        }
      } catch (Exception e) {
        stopWatch.stop("DELIVERY.defer_failure", logMsg);
        reply = DeliveryReturnCode.TEMPORARY_FAILURE;
        logger.error("DID" + deliveryId + ": delivery failed (defered): ", e);
      }

      replies.put(recipient, reply); // set delivery status for invoker
View Full Code Here

Examples of com.facebook.presto.jdbc.internal.guava.base.Stopwatch

  @Nullable
  Map<K, V> loadAll(Set<? extends K> keys, CacheLoader<? super K, V> loader)
      throws ExecutionException {
    checkNotNull(loader);
    checkNotNull(keys);
    Stopwatch stopwatch = Stopwatch.createStarted();
    Map<K, V> result;
    boolean success = false;
    try {
      @SuppressWarnings("unchecked") // safe since all keys extend K
      Map<K, V> map = (Map<K, V>) loader.loadAll(keys);
      result = map;
      success = true;
    } catch (UnsupportedLoadingOperationException e) {
      success = true;
      throw e;
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new ExecutionException(e);
    } catch (RuntimeException e) {
      throw new UncheckedExecutionException(e);
    } catch (Exception e) {
      throw new ExecutionException(e);
    } catch (Error e) {
      throw new ExecutionError(e);
    } finally {
      if (!success) {
        globalStatsCounter.recordLoadException(stopwatch.elapsed(NANOSECONDS));
      }
    }

    if (result == null) {
      globalStatsCounter.recordLoadException(stopwatch.elapsed(NANOSECONDS));
      throw new InvalidCacheLoadException(loader + " returned null map from loadAll");
    }

    stopwatch.stop();
    // TODO(fry): batch by segment
    boolean nullsPresent = false;
    for (Map.Entry<K, V> entry : result.entrySet()) {
      K key = entry.getKey();
      V value = entry.getValue();
      if (key == null || value == null) {
        // delay failure until non-null entries are stored
        nullsPresent = true;
      } else {
        put(key, value);
      }
    }

    if (nullsPresent) {
      globalStatsCounter.recordLoadException(stopwatch.elapsed(NANOSECONDS));
      throw new InvalidCacheLoadException(loader + " returned null keys or values from loadAll");
    }

    // TODO(fry): record count of loaded entries
    globalStatsCounter.recordLoadSuccess(stopwatch.elapsed(NANOSECONDS));
    return result;
  }
View Full Code Here

Examples of com.google.common.base.Stopwatch

        shutdownCalled.set(false);
    }
   
    @Test(enabled=false)
    public void shouldCreateSingletonAndExitAfter1Second() throws Exception {
        Stopwatch sw = new Stopwatch().start();
       
        final TerminationEvent event = new SelfDestructingTerminationEvent(1, TimeUnit.SECONDS);
        LifecycleInjector.builder()
            // Example of a singleton that will be created
            .withAdditionalModules(new AbstractModule() {
                @Override
                protected void configure() {
                    bind(SomeSingleton.class).asEagerSingleton();
                }
            })
            .withAdditionalBootstrapModules(
                StandaloneRunnerModule.builder()
                    .withTerminateEvent(event)
                    .build())
            .build()
            .createInjector();
       
        event.await();
        long elapsed = sw.elapsed(TimeUnit.MILLISECONDS);
        LOG.info("Elapsed: " + elapsed);
        Assert.assertTrue(initCalled.get());
        Assert.assertTrue(shutdownCalled.get());
        Assert.assertTrue(elapsed > 1000);
       
View Full Code Here

Examples of com.google_voltpatches.common.base.Stopwatch

     * {@link Service#startAsync()}.
     */
    void tryStartTiming(Service service) {
      monitor.enter();
      try {
        Stopwatch stopwatch = startupTimers.get(service);
        if (stopwatch == null) {
          startupTimers.put(service, Stopwatch.createStarted());
        }
      } finally {
        monitor.leave();
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.