當前位置: 首頁>>代碼示例>>Java>>正文


Java StopWatch類代碼示例

本文整理匯總了Java中org.apache.commons.lang.time.StopWatch的典型用法代碼示例。如果您正苦於以下問題:Java StopWatch類的具體用法?Java StopWatch怎麽用?Java StopWatch使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StopWatch類屬於org.apache.commons.lang.time包,在下文中一共展示了StopWatch類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: queryAllThreads

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
static List<QueryResult> queryAllThreads(final LoomClient client, final TapestryDefinition tapestryDefinition) {
    List<QueryResult> queryResults = new ArrayList<QueryResult>(tapestryDefinition.getThreads().size());
    StopWatch watch = new StopWatch();
    watch.start();
    List<ThreadDefinition> threads = tapestryDefinition.getThreads();
    for (ThreadDefinition thread : threads) {
        String threadId = thread.getId();
        QueryResult qr =
                getThreadWithWait(client, tapestryDefinition.getId(), threadId, IntegrationTestBase.greaterThan0);
        assertFalse("Result of a query did not contain elements for " + threadId, qr.getElements().isEmpty());
        queryResults.add(qr);
    }
    watch.stop();
    log.info("Getting all threads time=" + watch);
    assertFalse("Loom stuck in performance black hole", watch.getTime() > (60 * 1000));
    RelationshipsHandling.checkCrossThreadRelationships(queryResults);
    return queryResults;
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:19,代碼來源:BasicQueryOperations.java

示例2: testSerializePerformance

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Test
public void testSerializePerformance() throws IOException {
    Object obj = createTest();

    for (int x = 0; x < 20; ++x) {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        for (int i = 0; i < TIMES; ++i) {
            jsonSerialize(obj);
        }
        stopWatch.stop();

        System.out.println("JSON serialize:" + stopWatch.getTime());

        stopWatch.reset();
        stopWatch.start();
        for (int i = 0; i < TIMES; ++i) {
            javaSerialize(obj);
        }
        stopWatch.stop();
        System.out.println("JAVA serialize:" + stopWatch.getTime());
        System.out.println();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:TestFastJson.java

示例3: getServiceMappings

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
public List<EsServiceMapping> getServiceMappings() throws Exception {
  StopWatch sw = new StopWatch();
  sw.start();
  List<EsServiceMapping> ret = new ArrayList<>();
  SearchResponse result = getByDocType(10000);
  for (SearchHit hit : result.getHits()) {
    try {
      EsServiceMapping
          serviceMapping =
          mapper.readValue(hit.getSourceAsString(), EsServiceMapping.class);
      serviceMapping.buildMatchPatterns();
      ret.add(serviceMapping);
    } catch (Exception ex) {
      logger.error("Cannot create Service mapping from {}", hit.getSourceAsString());
    }
  }
  sw.stop();
  logger.info("Refresh all service mappings in {} ms", sw.getTime());
  return ret;
}
 
開發者ID:pinterest,項目名稱:soundwave,代碼行數:21,代碼來源:EsServiceMappingStore.java

示例4: run

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Override
public boolean run() {
    if (!CheckDBWorker.isDBOK) {
        return true;
    }
    logger.info("callback-log delete worker is starting ...");
    StopWatch clock = new StopWatch();
    try {
        clock.start();     // 計時開始
        callbackLogServiceImpl.deleteByTime();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return false;
    } finally {
        clock.stop();      // 計時結束
    }
    logger.info("callback-log delete worker is finished ...... it elapse time: " + clock.getTime() + " ms");
    return true;
}
 
開發者ID:tiglabs,項目名稱:jsf-core,代碼行數:20,代碼來源:CallbackLogWorker.java

示例5: run

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Override
public boolean run() {
    if (!CheckDBWorker.isDBOK) {
        return true;
    }
    logger.info("servicetrace-log delete worker is starting ...");
    StopWatch clock = new StopWatch();
    try {
        clock.start();     // 計時開始
        serviceTraceLogServiceImpl.deleteByTime();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        return false;
    } finally {
        clock.stop();      // 計時結束
    }
    logger.info("servicetrace-log delete worker is finished ...... it elapse time: " + clock.getTime() + " ms");
    return true;
}
 
開發者ID:tiglabs,項目名稱:jsf-core,代碼行數:20,代碼來源:ServiceTraceLogWorker.java

示例6: removeStitchedItems

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Override
public void removeStitchedItems(final String typeId, final String providerId) {

    if (!allowStitching) {
        return;
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("Remove all stitched items typeId=" + typeId + " providerId=" + providerId);
    }

    if (ruleManager.rulesExistForItemTypeId(typeId)) {
        StopWatch watch = new StopWatch();
        watch.start();
        // There may be stitches for this item type, which are removed by this call to
        // itemIndexer.
        itemIndexer.removeAllItemsForTypeIdAndProviderId(typeId, providerId);
        itemAttributeIndexer.removeAllItemsForTypeIdAndProviderId(typeId, providerId);
        watch.stop();
        LOG.info("removeStitchedItems " + typeId + " " + providerId + " time=" + watch);
    }
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:23,代碼來源:TestStitcherSession.java

示例7: get

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
private <T> T get(final String url, final java.lang.Class<T> tClass, final Object... uriVariables) {
    setErrorHandler();
    StopWatch watch = new StopWatch();
    watch.start();
    // T object = restTemplate.getForObject(url, tClass, uriVariables);

    ResponseEntity<T> response = restTemplate.getForEntity(url, tClass, uriVariables);
    HttpHeaders headers = response.getHeaders();

    List<String> cookies = headers.get("Set-Cookie");
    if (cookies != null && cookies.size() > 0) {
        for (String cookie : cookies) {
            if (cookie.substring(0, cookie.indexOf("=")).equals(LoomClient.SESSION_COOKIE)) {
                sessionId = cookie.substring(cookie.indexOf("=") + 1, cookie.indexOf(";"));
                if (sessionId.equals("")) {
                    sessionId = null;
                }
                break;
            }
        }
    }

    watch.stop();
    if (log.isTraceEnabled()) {
        String args = "";
        for (Object arg : uriVariables) {
            args += " " + arg;
        }
        if (watch.getTime() > timewarning) {
            log.trace("GET " + url + " " + args + " WARNING: Operation took " + watch);
        } else {
            log.trace("GET " + url + " " + args + " Operation took " + watch);
        }
    }

    return response.getBody();
    // return object;
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:39,代碼來源:RestClient.java

示例8: testGetSameQuery

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Test
public void testGetSameQuery()
        throws NoSuchSessionException, NoSuchTapestryDefinitionException, IllegalAccessException,
        UnsupportedOperationException, OperationException, NoSuchAggregationException, InvalidQueryInputException,
        LogicalIdAlreadyExistsException, NoSuchQueryDefinitionException, NoSuchThreadDefinitionException,
        OperationNotSupportedException, InvalidQueryParametersException, PendingQueryResultsException,
        ItemPropertyNotFound, RelationPropertyNotFound, IllegalArgumentException, ThreadDeletedByDynAdapterUnload {

    tap = new TapestryDefinition();
    tap.setThreads(identityThreads);
    tapestryManager.setTapestryDefinition(session, tap);

    StopWatch watch = new StopWatch();
    LOG.info("testing Get Same Query process");
    watch.start();
    QueryResult results = queryExec.processQuery(session, tap.getThreads().get(0));
    QueryResult sameResults = queryExec.processQuery(session, tap.getThreads().get(0));

    assertTrue(results.getLogicalId().equals(sameResults.getLogicalId()));
    assertTrue(results.getElements().size() == sameResults.getElements().size());

    watch.stop();
    LOG.info("tested Get Same Query process --> " + watch);
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:25,代碼來源:QueryExecutorImplTest.java

示例9: testVolumeJson

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Test
public void testVolumeJson() throws Exception {
    StopWatch watch = new StopWatch();
    LOG.info("testing VolumeJson");
    watch.start();
    // create a volume Item
    ItemType type = new OsVolumeType(provider);
    type.setId("os-" + type.getLocalId());
    OsVolume volume = new OsVolume("/os/fake/volumes/v1", type);
    OsVolumeAttributes ova =
            new OsVolumeAttributes("v1", "vId1", 40, "AVAILABLE", "zone", new Date().toString(), "None", "1234");
    ova.setItemDescription("A description");
    volume.setCore(ova);
    LOG.info("created JSON is\n" + toJson(volume));
    watch.stop();
    LOG.info("tested VolumeJson --> " + watch);
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:18,代碼來源:OsItemTest.java

示例10: nonExistentSession

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Test(expected = NoSuchSessionException.class)
public void nonExistentSession()
        throws NoSuchSessionException, NoSuchTapestryDefinitionException, LogicalIdAlreadyExistsException,
        NoSuchAggregationException, IllegalAccessException, OperationException, UnsupportedOperationException,
        InvalidQueryInputException, NoSuchQueryDefinitionException, NoSuchThreadDefinitionException,
        OperationNotSupportedException, InvalidQueryParametersException, PendingQueryResultsException,
        ItemPropertyNotFound, RelationPropertyNotFound, IllegalArgumentException, ThreadDeletedByDynAdapterUnload {
    tap = new TapestryDefinition();
    tap.setThreads(groupBraidThreads);
    tapestryManager.setTapestryDefinition(session, tap);

    StopWatch watch = new StopWatch();
    LOG.info("testing bad session process");
    watch.start();
    queryExec.processQuery(new SessionImpl(UUID.randomUUID().toString(), sessionManager.getInterval()),
            tap.getThreads().get(0));

    watch.stop();
    LOG.info("tested bad session process --> " + watch);
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:21,代碼來源:QueryExecutorImplTest.java

示例11: nonExistentAggregation

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Test(expected = NoSuchAggregationException.class)
public void nonExistentAggregation()
        throws NoSuchSessionException, NoSuchTapestryDefinitionException, LogicalIdAlreadyExistsException,
        NoSuchAggregationException, IllegalAccessException, OperationException, UnsupportedOperationException,
        InvalidQueryInputException, NoSuchQueryDefinitionException, NoSuchThreadDefinitionException,
        OperationNotSupportedException, InvalidQueryParametersException, PendingQueryResultsException,
        ItemPropertyNotFound, RelationPropertyNotFound, IllegalArgumentException, ThreadDeletedByDynAdapterUnload {
    tap = new TapestryDefinition();
    tap.setThreads(groupBraidThreads);
    tapestryManager.setTapestryDefinition(session, tap);

    StopWatch watch = new StopWatch();
    LOG.info("testing bad aggregation process");
    List<String> badSources = new ArrayList<>(1);
    badSources.add("/bad/sources");

    watch.start();
    groupBraidQuery.setInputs(badSources);
    queryExec.processQuery(session, tap.getThreads().get(0));

    watch.stop();
    LOG.info("tested bad aggregation process --> " + watch);
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:24,代碼來源:QueryExecutorImplTest.java

示例12: testWrongUUIDRegister

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Test
public void testWrongUUIDRegister() {
    StopWatch watch = new StopWatch();
    LOG.info("testing OpMgrRegistration");
    watch.start();

    List<String> opList = opMgr.listOperations(UUID.randomUUID());
    assertTrue(opList.size() == 0);

    opMgr.registerOperation("FAKEOP", firstMeta, UUID.randomUUID());
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    opMgr.registerOperation("", firstMeta, OperationManagerImpl.LOOM_UUID);
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    opMgr.registerOperation("FAKEOP", null, OperationManagerImpl.LOOM_UUID);
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    watch.stop();
    LOG.info("tested OpMgrRegistration --> " + watch);

}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:23,代碼來源:OperationManagerImplTest.java

示例13: testWrongProviderRegister

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Test
public void testWrongProviderRegister() {
    StopWatch watch = new StopWatch();
    LOG.info("testing OpMgrRegistration");
    watch.start();

    opMgr.registerOperation4Provider("FAKEOP", firstMeta, null);
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    opMgr.registerOperation4Provider("", firstMeta, new ProviderImpl("test", "test", "none", "test", "com"));
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    opMgr.registerOperation4Provider("FAKEOP", null, new ProviderImpl("test", "test", "none", "test", "com"));
    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    watch.stop();
    LOG.info("tested OpMgrRegistration --> " + watch);
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:19,代碼來源:OperationManagerImplTest.java

示例14: testRegionCreation

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Test
public void testRegionCreation() {
    StopWatch watch = new StopWatch();
    LOG.info("testing RegionCreation");
    watch.start();
    // create an instance Item
    String logicalId = "/os/fake/regions/r1";
    String name = "r1";
    String provId = "fake";
    ItemType type = new OsRegionType();
    type.setId("os-" + type.getLocalId());
    OsRegion item = new OsRegion(logicalId, type);
    OsRegionAttributes ora = new OsRegionAttributes();
    ora.setItemId(name);
    ora.setItemName(name);
    ora.setProviderId(provId);
    item.setCore(ora);
    assertEquals("Incorrect logicalId after creation", logicalId, item.getLogicalId());
    assertEquals("Incorrect name after creation", name, item.getCore().getItemName());
    assertEquals("Incorrect id after creation", name, item.getCore().getItemId());
    assertEquals("Incorrect providerId after creation", provId, item.getCore().getProviderId());
    assertEquals("Incorrect type after creation", type, item.getItemType());
    watch.stop();
    LOG.info("tested RegionCreation --> " + watch);
}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:26,代碼來源:OsItemTest.java

示例15: deleteAllOps4ProviderWrongly

import org.apache.commons.lang.time.StopWatch; //導入依賴的package包/類
@Test
public void deleteAllOps4ProviderWrongly() {
    StopWatch watch = new StopWatch();
    LOG.info("testing OpMgrDelete");
    watch.start();

    assertEquals(startValues, opMgr.listOperations(OperationManagerImpl.LOOM_UUID).size());

    opMgr.registerOperation4Provider("", firstMeta, new ProviderImpl("test", "test", "none", "test", "com"));
    assertEquals(DefaultOperations.values().length,
            opMgr.listOperations(new ProviderImpl("test", "test", "none", "test", "com")).size());

    opMgr.registerOperation4Provider("FAKEOP2", null, new ProviderImpl("test", "test", "none", "test", "com"));
    assertEquals(DefaultOperations.values().length,
            opMgr.listOperations(new ProviderImpl("test", "test", "none", "test", "com")).size());


}
 
開發者ID:HewlettPackard,項目名稱:loom,代碼行數:19,代碼來源:OperationManagerImplTest.java


注:本文中的org.apache.commons.lang.time.StopWatch類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。