本文整理汇总了Java中org.apache.commons.lang3.time.StopWatch.start方法的典型用法代码示例。如果您正苦于以下问题:Java StopWatch.start方法的具体用法?Java StopWatch.start怎么用?Java StopWatch.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.time.StopWatch
的用法示例。
在下文中一共展示了StopWatch.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteInstance
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
/**
* Requests deletion of the instance, without creating a final snapshot or deleting any other related
* snapshots.
* <p/>
* Caller must wait for status=deleted or DBInstanceNotFoundException afterwards.
*/
public DBInstance deleteInstance(String instanceName)
{
LOGGER.debug("deleteDBInstance(instanceName: " + instanceName + ")");
StopWatch stopWatch = new StopWatch();
try
{
stopWatch.start();
DeleteDBInstanceRequest request = new DeleteDBInstanceRequest(instanceName);
request.setSkipFinalSnapshot(true);
return awsRdsClient.deleteDBInstance(request);
}
finally
{
stopWatch.stop();
LOGGER.debug("deleteDBInstance time elapsed: " + stopWatch);
}
}
示例2: start
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
public void start() throws Exception {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
//游戏基础框架服务启动
frameworkInit();
//游戏业务初始化
gameLogicInit();
stopWatch.stop();
logger.error("游戏服务启动,耗时[{}]毫秒", stopWatch.getTime());
//mbean监控
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
GameMonitorMXBean controller = new GameMonitor();
mbs.registerMBean(controller, new ObjectName("GameMXBean:name=GameMonitor"));
}
示例3: findAllLinksInLinkMappingWithParent
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
public ObservableList<Link> findAllLinksInLinkMappingWithParent(final long parentId, final LinkMappingType parentType) {
final StopWatch stopWatch = new StopWatch();
stopWatch.start();
final ObservableList<LinkMapping> allLinkMappingsWithParent = LinkMappingSqlService.getDefault().findAllLinksInLinkMappingWithParent(parentId, parentType);
final ObservableList<Link> links = FXCollections.observableArrayList();
allLinkMappingsWithParent.stream()
.forEach(linkMapping -> {
final Optional<Link> optional = this.findById(Link.class, linkMapping.getChildId());
if (optional.isPresent()) {
links.add(optional.get());
}
});
stopWatch.split();
this.printToLog(stopWatch.toSplitString(), allLinkMappingsWithParent.size(), "findAllLinksInLinkMappingWithPrimary(long, LinkMappingType)"); // NOI18N
stopWatch.stop();
return links;
}
示例4: rebootInstance
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
/**
* Requests a reboot of the instance.
* <p/>
* Caller must wait for status=available afterwards.
*/
public DBInstance rebootInstance(String instanceId)
{
LOGGER.debug("rebootDBInstance(instanceName: " + instanceId + ")");
StopWatch stopWatch = new StopWatch();
try
{
stopWatch.start();
RebootDBInstanceRequest request = new RebootDBInstanceRequest(instanceId);
return awsRdsClient.rebootDBInstance(request);
}
finally
{
stopWatch.stop();
LOGGER.debug("rebootDBInstance time elapsed: " + stopWatch);
}
}
示例5: deleteParameterGroup
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
/**
* Deletes the parameter group. (Assuming it is not in use by any database instance.)
*/
public void deleteParameterGroup(String paramGroupName)
{
LOGGER.debug("deleteDBParameterGroup(paramGroupName: " + paramGroupName + ")");
StopWatch stopWatch = new StopWatch();
try
{
stopWatch.start();
DeleteDBParameterGroupRequest request = new DeleteDBParameterGroupRequest(paramGroupName);
awsRdsClient.deleteDBParameterGroup(request);
}
finally
{
stopWatch.stop();
LOGGER.debug("deleteDBParameterGroup time elapsed: " + stopWatch);
}
}
示例6: createSnapshot
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
/**
* Creates an RDS instance snapshot using the specified snapshot id.
* <p/>
* Caller must wait for status=available afterwards.
*/
public DBSnapshot createSnapshot(String snapshotId, String instanceName)
{
LOGGER.debug("createDBSnapshot(snapshotId: " + snapshotId + ", instanceName: " + instanceName + ")");
StopWatch stopWatch = new StopWatch();
try
{
stopWatch.start();
CreateDBSnapshotRequest request = new CreateDBSnapshotRequest(snapshotId, instanceName);
return awsRdsClient.createDBSnapshot(request);
}
finally
{
stopWatch.stop();
LOGGER.debug("createDBSnapshot time elapsed: " + stopWatch);
}
}
示例7: timed
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
/**
* Executes the specified runnable in a timed block, and prints the measured
* time to the specified logger, with the specified prefix.
*
* @param log
* the logger to print the result to
* @param prefix
* the prefix in the printed message
* @param f
* the runnable to time
*/
public static void timed( Logger log, String prefix, Runnable f )
{
StopWatch sw = new StopWatch();
sw.start();
f.run();
sw.stop();
log.trace(
String.format(
"%s: %sms (%sns)",
prefix, sw.getTime(), sw.getNanoTime()
)
);
}
示例8: monitorElapsedTime
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
/**
* Monitor the elapsed time of method on controller layer, in
* order to detect performance problems as soon as possible.
* If elapsed time > 1 s, log it as an error. Otherwise, log it
* as an info.
*/
@Around("controllerLayer()")
public Object monitorElapsedTime(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
// Timing the method in controller layer
StopWatch stopWatch = new StopWatch();
stopWatch.start();
Object result = proceedingJoinPoint.proceed();
stopWatch.stop();
// Log the elapsed time
double elapsedTime = stopWatch.getTime() / 1000.0;
Signature signature = proceedingJoinPoint.getSignature();
String infoString = "[" + signature.toShortString() + "][Elapsed time: " + elapsedTime + " s]";
if (elapsedTime > 1) {
log.error(infoString + "[Note that it's time consuming!]");
} else {
log.info(infoString);
}
// Return the result
return result;
}
示例9: testSign
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
@Test
public void testSign() {
StopWatch watch = new StopWatch();
watch.start();
String sig = EncryptUtils.signByHmacSHA1(TEST_PLAIN_TEXT, TEST_PASSWORD);
watch.stop();
System.out.printf("%d\tms: HmacSHA1 (%s)\n", watch.getTime(), sig);
assertTrue(EncryptUtils.verifyByHmacSHA1(TEST_PLAIN_TEXT, TEST_PASSWORD, sig));
watch.reset();
watch.start();
sig = EncryptUtils.sha1Hex(TEST_PLAIN_TEXT, TEST_PASSWORD, TEST_PASSWORD);
watch.stop();
System.out.printf("%d\tms: SHA1 (%s)\n", watch.getTime(), sig);
assertTrue(EncryptUtils.verifyBySHA1(TEST_PLAIN_TEXT, TEST_PASSWORD, TEST_PASSWORD, sig));
watch.reset();
watch.start();
sig = EncryptUtils.md5Hex(TEST_PLAIN_TEXT, TEST_PASSWORD);
watch.stop();
System.out.printf("%d\tms: MD5 (%s)\n", watch.getTime(), sig);
assertTrue(EncryptUtils.verifyByMD5(TEST_PLAIN_TEXT, TEST_PASSWORD, sig));
}
示例10: applyProducers
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
private void applyProducers(List<Mutant<A>> mutants) {
for (MutantProducer<A> producer : producers) {
// Time the application of each producer
StopWatch timer = new StopWatch();
timer.start();
List<Mutant<A>> producerMutants = producer.mutate();
timer.stop();
producerTimings.put(producer.getClass(), timer);
// Record how many mutants were added by the operator
int newMutants = producerMutants.size();
Class producerClass = producer.getClass();
// Following 2 lines are for compatibility with higher-order mutation
int producerCount = producerCounts.containsKey(producerClass) ? producerCounts.get(producerClass) : 0;
producerCounts.put(producerClass, producerCount + newMutants);
// Store the name of the operator as the simple description
String simpleDescription = producer.getClass().getSimpleName();
for (Mutant<A> mutant : producerMutants) {
mutant.setSimpleDescription(simpleDescription);
}
mutants.addAll(producerMutants);
}
}
示例11: testBlockerExceeding
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
@Test
public void testBlockerExceeding() {
Blocker blocker = new Blocker(TIMEOUT, BLOCK_TIME, MESSAGE);
StopWatch stopWatch = new StopWatch();
stopWatch.start();
int callCounter = 0;
while (true) {
try {
blocker.block();
callCounter++;
} catch (ResourceException e) {
stopWatch.stop();
break;
}
}
assertEquals(TIMEOUT / BLOCK_TIME, callCounter, 0.1);
assertEquals(TIMEOUT, stopWatch.getTime() / 1000, 0.1);
}
示例12: testRetrieveCustomRecordCustomFields
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
@Test
public void testRetrieveCustomRecordCustomFields() throws Exception {
NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
connection.login();
StopWatch stopWatch = new StopWatch();
stopWatch.start();
RecordTypeInfo recordType = connection.getMetaDataSource()
.getRecordType("customrecord_campaign_revenue");
TypeDesc typeDesc = connection.getMetaDataSource().getTypeInfo(recordType.getName());
logger.debug("Record type desc: {}", typeDesc.getTypeName());
stopWatch.stop();
}
示例13: happy
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
@Test
@Ignore("Not to be used in normal unit tests. Here for real executions.")
public void happy() throws IOException, InterruptedException {
BiPredicate<URL, Integer>
shouldVisit = (url, depth) -> url.getHost().equals("news.yahoo.com");
shouldVisit = shouldVisit.and( (url, depth) -> depth < 5);
shouldVisit = shouldVisit.and( (url, depth) -> url.getPath().contains("obama"));
GrabManager grabManager = new GrabManager(15, shouldVisit);
StopWatch stopWatch = new StopWatch();
stopWatch.start();
grabManager.go(new URL("http://news.yahoo.com"));
stopWatch.stop();
System.out.println("Found " + grabManager.getMasterList().size() + " urls");
System.out.println("in " + stopWatch.getTime() / 1000 + " seconds");
}
示例14: get
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
@Override
public ObjectKeys get() {
LOG.info("Collect object keys");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
try (BufferedReader reader = new BufferedReader(new FileReader(new File(fileName)))) {
reader.lines().forEach(objectKeys::add);
} catch (IOException e) {
LOG.error("Could not read key file", e);
}
stopWatch.stop();
LOG.info("Time = {} ms", stopWatch.getTime());
LOG.info("Object keys: {}", objectKeys.size());
return objectKeys;
}
示例15: run
import org.apache.commons.lang3.time.StopWatch; //导入方法依赖的package包/类
private void run( final AnalysisLaunchArguments launchArgs ) throws ServiceException {
final EquityConfiguration equity = equity(launchArgs);
final BacktestBootstrapConfiguration backtestConfiguration = configuration(equity, launchArgs.openingFunds());
recordStrategy(backtestConfiguration.strategy());
recordAnalysisPeriod(backtestConfiguration.backtestDates());
final StopWatch timer = new StopWatch();
timer.start();
try {
new Backtest(dataService, dataServiceUpdater).run(equity, backtestConfiguration.backtestDates(),
context(backtestConfiguration, output()), output());
} finally {
HibernateUtil.sessionFactory().close();
}
timer.stop();
recordExecutionTime(timer);
}