当前位置: 首页>>代码示例>>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;未经允许,请勿转载。