Example usage for org.apache.commons.lang.time StopWatch stop

List of usage examples for org.apache.commons.lang.time StopWatch stop

Introduction

In this page you can find the example usage for org.apache.commons.lang.time StopWatch stop.

Prototype

public void stop() 

Source Link

Document

Stop the stopwatch.

This method ends a new timing session, allowing the time to be retrieved.

Usage

From source file:org.openscore.lang.cli.SlangCLI.java

@CliCommand(value = "run", help = "triggers a slang flow")
public String run(@CliOption(key = { "", "f",
        "file" }, mandatory = true, help = "Path to filename. e.g. slang run --f C:\\Slang\\flow.yaml") final File file,
        @CliOption(key = { "cp",
                "classpath" }, mandatory = false, help = "Classpath , a directory comma separated list to flow dependencies, by default it will take flow file dir") final List<String> classPath,
        @CliOption(key = { "i",
                "inputs" }, mandatory = false, help = "inputs in a key=value comma separated list") final Map<String, Serializable> inputs,
        @CliOption(key = { "spf",
                "system-property-file" }, mandatory = false, help = "comma separated list of system property file locations") final List<String> systemPropertyFiles)
        throws IOException {

    CompilationArtifact compilationArtifact = compilerHelper.compile(file.getAbsolutePath(), null, classPath);
    Map<String, ? extends Serializable> systemProperties = compilerHelper
            .loadSystemProperties(systemPropertyFiles);
    Long id;/*from w  ww . j  ava2 s .com*/
    if (!triggerAsync) {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        id = scoreServices.triggerSync(compilationArtifact, inputs, systemProperties);
        stopWatch.stop();
        return triggerSyncMsg(id, stopWatch.toString());
    }
    id = scoreServices.trigger(compilationArtifact, inputs, systemProperties);
    return triggerAsyncMsg(id, compilationArtifact.getExecutionPlan().getName());
}

From source file:org.opentestsystem.delivery.testreg.rest.StudentPackageController.java

@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/studentpackage", method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE)
@Secured({ "ROLE_Entity Read" })
@ResponseBody/* ww  w .j a v  a2  s.  co  m*/
public void extractStudentPackage(@RequestParam(value = "ssid", required = false) final String studentId,
        @RequestParam(value = "externalId", required = false) final String externalSsid,
        @RequestParam("stateabbreviation") final String stateAbbreviation, final HttpServletResponse response)
        throws IOException {
    StopWatch sw = new StopWatch();
    sw.start();
    Student student = null;

    if (hasText(studentId) && hasText(externalSsid)) {
        response.setStatus(HttpServletResponse.SC_CONFLICT);
    } else if (hasText(studentId)) {
        student = studentService.findByStudentIdAndStateAbbreviation(studentId, stateAbbreviation);
    } else if (hasText(externalSsid)) {
        student = studentService.findByExternalSsidAndStateAbbreviation(externalSsid, stateAbbreviation);
    }

    if (student != null) {
        String studentPackage = studentPackageService.exportStudentPackage(student);
        response.setContentType(MediaType.APPLICATION_XML_VALUE);
        ServletOutputStream out = response.getOutputStream();
        IOUtils.copy(new ByteArrayInputStream(studentPackage.getBytes()), out);
        out.flush();
    } else {
        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
    }
    sw.stop();
    this.metricClient.sendPerformanceMetricToMna("StudentPackage for " + externalSsid + " (ms) ", sw.getTime());
}

From source file:org.pdfsam.guiclient.gui.frames.JMainFrame.java

public JMainFrame() {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();//w  w  w.  j  a  v a 2s.c o m
    log.info("Starting " + GuiClient.getApplicationName() + " Ver. " + GuiClient.getVersion());
    runSplash();
    ToolTipManager.sharedInstance().setDismissDelay(300000);
    initialize();
    closeSplash();
    stopWatch.stop();
    log.info(GuiClient.getApplicationName() + " Ver. " + GuiClient.getVersion() + " "
            + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "started in ")
            + DurationFormatUtils.formatDurationWords(stopWatch.getTime(), true, true));
}

From source file:org.rhq.server.metrics.migrator.DataSourceTest.java

public static void main(String[] args) throws Exception {
    BasicConfigurator.configure();/*www.  ja v  a  2s  .c om*/
    Logger.getRootLogger().setLevel(Level.INFO);
    Logger.getLogger("org.rhq").setLevel(Level.DEBUG);
    EntityManagerFactory entityManagerFactory = null;
    EntityManager entityManager = null;
    ExistingDataBulkExportSource source = null;
    try {
        entityManagerFactory = createEntityManager();
        entityManager = entityManagerFactory.createEntityManager();
        source = new ExistingPostgresDataBulkExportSource(entityManager,
                "SELECT  schedule_id, time_stamp, value, minvalue, maxvalue FROM RHQ_MEASUREMENT_DATA_NUM_1D");
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        source.initialize();
        int rowIndex = 0;
        int maxResults = 30000;
        for (;;) {
            List<Object[]> existingData = source.getData(rowIndex, maxResults);
            if (existingData.size() < maxResults) {
                break;
            } else {
                rowIndex += maxResults;
            }
        }
        stopWatch.stop();
        System.out.println("Execution: " + stopWatch);
    } finally {
        if (source != null) {
            source.close();
        }
        if (entityManager != null) {
            entityManager.close();
        }
        if (entityManagerFactory != null) {
            entityManagerFactory.close();
        }
    }
}

From source file:org.rhq.server.metrics.migrator.DataSourceTest.java

public static void main2(String[] args) throws Exception {
    BasicConfigurator.configure();/*from  w  w  w . j  ava  2s.  c  o m*/
    Logger.getRootLogger().setLevel(Level.INFO);
    Logger.getLogger("org.rhq").setLevel(Level.DEBUG);
    EntityManagerFactory entityManagerFactory = null;
    EntityManager entityManager = null;
    ExistingDataBulkExportSource source = null;
    try {
        entityManagerFactory = createEntityManager();
        entityManager = entityManagerFactory.createEntityManager();
        source = new ExistingPostgresDataBulkExportSource(entityManager,
                "SELECT  schedule_id, time_stamp, value, minvalue, maxvalue FROM RHQ_MEASUREMENT_DATA_NUM_1D");
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        source.initialize();
        int rowIndex = 0;
        int maxResults = 30000;
        for (;;) {
            List<Object[]> existingData = source.getData(rowIndex, maxResults);
            if (existingData.size() < maxResults) {
                break;
            } else {
                rowIndex += maxResults;
            }
        }
        stopWatch.stop();
        System.out.println("Execution: " + stopWatch);
    } finally {
        if (source != null) {
            source.close();
        }
        if (entityManager != null) {
            entityManager.close();
        }
        if (entityManagerFactory != null) {
            entityManagerFactory.close();
        }
    }
}

From source file:org.sonatype.nexus.integrationtests.nexus748.Nexus748MultipleStart.java

@Test
public void multipleStartTest() throws Exception {

    StopWatch stopWatch = new StopWatch();

    NexusClient client = (NexusClient) getITPlexusContainer().lookup(NexusClient.ROLE);
    TestContext context = TestContainer.getInstance().getTestContext();
    client.connect(AbstractNexusIntegrationTest.nexusBaseUrl, context.getAdminUsername(),
            context.getAdminPassword());

    // enable security
    getNexusConfigUtil().enableSecurity(true);

    List<Long> startTimes = new ArrayList<Long>();

    for (int ii = 0; ii < 10; ii++) {
        // start the timer
        stopWatch.reset();// w  w w  .  j av a  2  s.co m
        stopWatch.start();

        // start
        getNexusStatusUtil().start(getTestId());

        Assert.assertTrue(client.isNexusStarted(true));

        // get the time
        stopWatch.stop();

        // stop
        getNexusStatusUtil().stop();

        startTimes.add(stopWatch.getTime());
    }

    logger.info("\n\n**************\n Start times: \n**************");

    logger.info("Iter\tTime");
    for (int ii = 0; ii < startTimes.size(); ii++) {
        Long startTime = startTimes.get(ii);
        logger.info(" " + (ii + 1) + "\t " + (startTime / 1000.0) + "sec.");

    }

}

From source file:org.springframework.integration.activiti.namespace.gateway.GatewayNamespaceTest.java

@Deployment(resources = "processes/si_gateway_example.bpmn20.xml")
public void testAsync() throws Throwable {

    // get the process engine
    processEngine.getRepositoryService().createDeployment()
            .addClasspathResource("processes/si_gateway_example.bpmn20.xml").deploy();

    // launch a process
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("customerId", 232);
    vars.put("orderNo", 223);
    vars.put("sku", "242421gfwe");

    log.debug("about to start the business process");
    StopWatch sw = new StopWatch();
    sw.start();/*w  w  w  .ja va 2 s  .  com*/
    processEngine.getRuntimeService().startProcessInstanceByKey("sigatewayProcess", vars);

    sw.stop();
    log.debug("total time to run the process:" + sw.getTime());

    Thread.sleep(1000 * 5);

}

From source file:org.thiesen.ant.git.ExtractGitInfo.java

@Override
public void execute() throws BuildException {
    if (getBaseDir() == null) {
        throw new BuildException("baseDir property must be set.");
    }//  w ww .  j  av  a2 s . co  m

    if (!getBaseDir().exists()) {
        throw new BuildException("Base dir " + getBaseDir().getAbsolutePath() + " does not exist!");
    }

    try {
        final StopWatch watch = new StopWatch();
        watch.start();
        final GitInfo info = GitInfoExtractor.extractInfo(getBaseDir());
        watch.stop();

        log("This is GitAnt " + loadVersion());
        log("Using " + loadJGitVersion());
        log("Data collection took " + watch);

        if (isDisplayInfo()) {
            log(info.getDisplayString(), Project.MSG_INFO);
        }

        final Project currentProject = getProject();
        if (currentProject != null) {
            exportProperties(info, currentProject);
        }

    } catch (final IOException e) {
        throw new BuildException(e);
    }
}

From source file:org.trend.hgraph.mapreduce.pagerank.CalculateInitPageRankMapper.java

static void dispatchPageRank(List<String> outgoingRowKeys, double pageRank, Configuration conf,
        HTable edgeTable, Counter dispatchPrTimeConsumeCounter, Counter outgoingEdgeCounter,
        ContextWriterStrategy strategy) throws IOException, InterruptedException {
    int outgoingEdgeCount = outgoingRowKeys.size();
    outgoingEdgeCounter.increment(outgoingEdgeCount);
    double pageRankForEachOutgoing = pageRank / (double) outgoingEdgeCount;

    StopWatch sw = null;
    String outgoingRowKey = null;
    try {//from   w w  w  . j a  v  a 2s. com
        sw = new StopWatch();
        sw.start();
        for (int a = 0; a < outgoingRowKeys.size(); a++) {
            outgoingRowKey = outgoingRowKeys.get(a);
            strategy.write(outgoingRowKey, pageRankForEachOutgoing);
        }
        sw.stop();
        dispatchPrTimeConsumeCounter.increment(sw.getTime());
    } catch (IOException e) {
        System.err.println("failed while writing outgoingRowKey:" + outgoingRowKey);
        e.printStackTrace(System.err);
        throw e;
    } catch (InterruptedException e) {
        System.err.println("failed while writing outgoingRowKey:" + outgoingRowKey);
        e.printStackTrace(System.err);
        throw e;
    }
}

From source file:org.trend.hgraph.mapreduce.pagerank.CalculateInitPageRankMapper.java

static List<String> getOutgoingRowKeys(Configuration conf, HTable vertexTable, HTable edgeTable, String rowKey,
        Counter counter) throws IOException {
    ResultScanner rs = null;/*from w  w  w  .j a va  2 s .c o  m*/
    String key = null;
    LinkedList<String> rowKeys = new LinkedList<String>();
    StopWatch sw = null;
    // Put put = null;
    try {
        Scan scan = getRowKeyOnlyScan(rowKey);
        sw = new StopWatch();
        sw.start();
        rs = edgeTable.getScanner(scan);
        for (Result r : rs) {
            key = getOutgoingRowKey(r);
            // collect outgoing rowkeys
            rowKeys.add(key);
        }
        sw.stop();
        counter.increment(sw.getTime());
    } catch (IOException e) {
        System.err.println("access htable:" + Bytes.toString(edgeTable.getTableName()) + " failed");
        e.printStackTrace(System.err);
        throw e;
    } finally {
        rs.close();
    }
    return rowKeys;
}