Examples of StopWatch


Examples of org.jboss.util.StopWatch

         final LifecycleState actual = this.getState();
         this.checkState(required, actual);

         // Initiate shutdown sequence
         log.info("Stopping: " + this);
         final StopWatch watch = new StopWatch(true);
         this.setState(LifecycleState.STOPPING);

         // Send JMX Notification
         this.sendStopJmxNotification();
View Full Code Here

Examples of org.jnode.util.StopWatch

public class InvokeInterfaceTest {

    public static void main(String[] args) {
        A a = new B();

        final StopWatch sw = new StopWatch();
        int a1 = 1;
        int a2 = 1;
        for (int i = 0; i < 10000; i++) {
            a1 = a.foo(a1);
            a2 = a.foo2(a1, a2);
View Full Code Here

Examples of org.jooq.tools.StopWatch

    // ----

    @Override
  public void generate(Database database) throws IOException {
        StopWatch watch = new StopWatch();

        log.info("Database parameters");
      log.info("----------------------------------------------------------");
      log.info("  dialect", database.getDialect());
      log.info("  target dir", getTargetDirectory());
View Full Code Here

Examples of org.modeshape.common.statistic.Stopwatch

        assertThat(system.getPath(), is("/jcr:system"));
    }

    @Test
    public void shouldAllowCreatingManyUnstructuredNodesWithSameNameSiblings() throws Exception {
        Stopwatch sw = new Stopwatch();
        System.out.print("Iterating ");
        for (int i = 0; i != 15; ++i) {
            System.out.print(".");
            // Each iteration adds another node under the root and creates the many nodes under that node ...
            Node node = session.getRootNode().addNode("testNode");
            session.save();

            if (i > 2) {
                sw.start();
            }
            for (int j = 0; j != MANY_NODES_COUNT; ++j) {
                node.addNode("childNode");
            }
            session.save();
            if (i > 2) {
                sw.stop();
            }

            // Now add another node ...
            node.addNode("oneMore");
            session.save();

            node.remove();
            session.save();
            assertThat(session.getRootNode().getNodes().getSize(), is(1L));
        }
        System.out.println();
        System.out.println(sw.getDetailedStatistics());
    }
View Full Code Here

Examples of org.nutz.lang.Stopwatch

    final Context context = Lang.context("{num:0}");
    context.set("z", z);

    System.out.println("\n" + Strings.dup('=', 100));

    Stopwatch sw = Stopwatch.run(new Atom() {
      public void run() {
        int num = 0;
        for (int i = 0; i < max; i++)
          num = num + (i - 1 + 2 - 3 + 4 - 5 + 6 - 7) - z.abc(i);
        System.out.println("Num: " + num);
      }
    });

    System.out.println("\n" + Strings.dup('=', 100));
   
    Stopwatch sw3 = Stopwatch.run(new Atom() {
      public void run() {
        try {
          context.set("num", 0);
          for (int i = 0; i < max; i++)
            context.set("num", El.eval(context.set("i", i), elstr));
          System.out.println("Num: " + context.getInt("num"));
        }
        catch (Exception e) {
          throw Lang.wrapThrow(e);
        }
      }
    });
    System.out.println("\n" + Strings.dup('=', 100));
   
    Stopwatch sw4 = Stopwatch.run(new Atom() {
      public void run() {
        try {
          El el2pre = new El(elstr);
          context.set("num", 0);
          context.set("z", z);
          for (int i = 0; i < max; i++)
            context.set("num", el2pre.eval(context.set("i", i)));
          System.out.println("Num: " + context.getInt("num"));
        }
        catch (Exception e) {
          throw Lang.wrapThrow(e);
        }
      }
    });
    System.out.println("\n" + Strings.dup('=', 100));
   
    Stopwatch sw5 = Stopwatch.run(new Atom() {
      public void run() {
        try {
          El el2pre = new El(elstr);
          context.set("num", 0);
          context.set("z", z);
          for (int i = 0; i < max; i++)
            context.set("num", el2pre.eval(context.set("i", i)));
          System.out.println("Num: " + context.getInt("num"));
        }
        catch (Exception e) {
          throw Lang.wrapThrow(e);
        }
      }
    });
    System.out.println("\n" + Strings.dup('=', 100));

    System.out.printf("\n%20s : %s", "Invoke", sw.toString());
    System.out.printf("\n%20s : %s", "Reflect", sw3.toString());
    System.out.printf("\n%20s : %s", "Reflect", sw4.toString());
    System.out.printf("\n%20s : %s", "Reflect", sw5.toString());
    System.out.println();

  }
View Full Code Here

Examples of org.pentaho.reporting.libraries.base.util.StopWatch

    final TestReportDesignerContext designerContext = new TestReportDesignerContext();
    final int idx = designerContext.addMasterReport(report);
    final ReportRenderContext masterContext = designerContext.getReportRenderContext(idx);

    final SharedElementRenderer sharedRenderer = masterContext.getSharedRenderer();
    final StopWatch w = StopWatch.startNew();
    run(mrLabel2, sharedRenderer);
    DebugLog.log(w);
  }
View Full Code Here

Examples of org.perf4j.StopWatch

    return stats;
  }


  public void operateWithFailover(Operation<?> op) throws HectorException {
    final StopWatch stopWatch = new Slf4JStopWatch(perf4jLogger);
    int retries = Math.min(op.failoverPolicy.numRetries, hostPools.size());
    HThriftClient client = null;
    boolean success = false;
    boolean retryable = false;
    Set<CassandraHost> excludeHosts = new HashSet<CassandraHost>();
    // TODO start timer for limiting retry time spent
    while ( !success ) {
      try {
        // TODO how to 'timeout' on this op when underlying pool is exhausted
        client =  getClientFromLBPolicy(excludeHosts);
        Cassandra.Client c = client.getCassandra(op.keyspaceName);
        // Keyspace can be null for some system_* api calls
        if ( !op.credentials.isEmpty() ) {
          c.login(new AuthenticationRequest(op.credentials));
        }

        op.executeAndSetResult(c, client.cassandraHost);
        success = true;
        stopWatch.stop(op.stopWatchTagName + ".success_");
        break;

      } catch (Exception ex) {
        HectorException he = exceptionsTranslator.translate(ex);
        if ( he instanceof HInvalidRequestException || he instanceof HCassandraInternalException ) {
          throw he;
        } else if ( he instanceof HectorTransportException) {
          --retries;
          client.close();
          markHostAsDown(client);
          excludeHosts.add(client.cassandraHost);
          retryable = true;
          if ( retries > 0 ) {
            monitor.incCounter(Counter.RECOVERABLE_TRANSPORT_EXCEPTIONS);
          }
        } else if (he instanceof HTimedOutException || he instanceof HUnavailableException ) {
          // DO NOT drecrement retries, we will be keep retrying on timeouts until it comes back
          retryable = true;
          monitor.incCounter(Counter.RECOVERABLE_TIMED_OUT_EXCEPTIONS);
          client.close();
          // TODO timecheck on how long we've been waiting on timeouts here
          // suggestion per user moores on hector-users
        } else if ( he instanceof PoolExhaustedException ) {
          retryable = true;
          --retries;
          if ( hostPools.size() == 1 ) {
            throw he;
          }
          monitor.incCounter(Counter.POOL_EXHAUSTED);
          excludeHosts.add(client.cassandraHost);
        }
        if ( retries <= 0 || retryable == false) throw he;
        log.error("Could not fullfill request on this host {}", client);
        log.error("Exception: ", he);
        monitor.incCounter(Counter.SKIP_HOST_SUCCESS);
        sleepBetweenHostSkips(op.failoverPolicy);
      } finally {
        if ( !success ) {
          monitor.incCounter(op.failCounter);
          stopWatch.stop(op.stopWatchTagName + ".fail_");
        }
        releaseClient(client);
      }
    }
  }
View Full Code Here

Examples of org.prevayler.foundation.StopWatch

  /**
   * @return The number of operations the test managed to execute per second with the given number of threads.
   */
  private double performRound(int threads) {
    long initialOperationCount = operationCount;
    StopWatch stopWatch = StopWatch.start();

    startThreads(threads);
    sleep();
    stopThreads();

    double secondsEllapsed = stopWatch.secondsEllapsed();
    double operationsPerSecond = (operationCount - initialOperationCount) / secondsEllapsed;

    out("\nMemory used: " + Runtime.getRuntime().totalMemory());
    subject.reportResourcesUsed(System.out);
    out("Seconds ellapsed: " + secondsEllapsed);
View Full Code Here

Examples of org.rhq.core.util.StopWatch

        return vacuum(whoami, TABLES_TO_VACUUM);
    }

    private long doCommand(DatabaseType dbtype, Connection conn, String command, String table) {
        Statement stmt = null;
        StopWatch watch = new StopWatch();

        if (table == null) {
            table = "";
        }

        command = command.replace("{0}", table);

        if (LOG.isDebugEnabled()) {
            LOG.debug("Execute command: " + command);
        }

        try {
            stmt = conn.createStatement();
            stmt.execute(command);
            return watch.getElapsed();
        } catch (SQLException e) {
            LOG.error("Error in command: " + command + ": " + e, e);
            return watch.getElapsed();
        } finally {
            dbtype.closeStatement(stmt);
        }
    }
View Full Code Here

Examples of org.rioproject.impl.watch.StopWatch

     * invocation takes
     *
     * @param watchRegistry The WatchRegistry to register the StopWatch
     */
    public void createWatch(WatchDataSourceRegistry watchRegistry) {
        responseWatch = new StopWatch(RESPONSE_WATCH + descriptor.toString());
        if(watchRegistry == null)
            return;
        this.watchRegistry = watchRegistry;
        watchRegistry.register(responseWatch);
    }
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.