本文整理匯總了Java中org.apache.commons.lang3.time.StopWatch.reset方法的典型用法代碼示例。如果您正苦於以下問題:Java StopWatch.reset方法的具體用法?Java StopWatch.reset怎麽用?Java StopWatch.reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.time.StopWatch
的用法示例。
在下文中一共展示了StopWatch.reset方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
/**
* Create database schema for tenant.
*
* @param tenant - the tenant
*/
public void create(Tenant tenant) {
StopWatch stopWatch = createStarted();
log.info("START - SETUP:CreateTenant:schema tenantKey={}", tenant.getTenantKey());
DatabaseUtil.createSchema(dataSource, tenant.getTenantKey());
log.info("STOP - SETUP:CreateTenant:schema tenantKey={}, time={}ms", tenant.getTenantKey(),
stopWatch.getTime());
try {
stopWatch.reset();
stopWatch.start();
log.info("START - SETUP:CreateTenant:liquibase tenantKey={}", tenant.getTenantKey());
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setResourceLoader(resourceLoader);
liquibase.setDataSource(dataSource);
liquibase.setChangeLog(CHANGE_LOG_PATH);
liquibase.setContexts(liquibaseProperties.getContexts());
liquibase.setDefaultSchema(tenant.getTenantKey());
liquibase.setDropFirst(liquibaseProperties.isDropFirst());
liquibase.setShouldRun(true);
liquibase.afterPropertiesSet();
log.info("STOP - SETUP:CreateTenant:liquibase tenantKey={}, time={}ms", tenant.getTenantKey(),
stopWatch.getTime());
} catch (LiquibaseException e) {
throw new RuntimeException("Can not migrate database for creation tenant " + tenant.getTenantKey(), e);
}
}
示例2: 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));
}
示例3: getResponseFromPrimedContext
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
@Test // primed, got
// 30_000, 1,000
// naive,loop 100, 10
// map, linear insert 100, 6
// map, get on insert 0.1, 0.005
public void getResponseFromPrimedContext() {
final StopWatch stopWatch = new StopWatch();
stopWatch.start();
primings.forEach(primingContext::add);
stopWatch.stop();
long time = stopWatch.getTime();
System.out.println(time + " ms elapsed inserting " + primings.size() + " primings");
stopWatch.reset();
stopWatch.start();
for (int i : indices) {
final AppRequest request = primings.get(i).getAppRequest();
primingContext.getResponse(request).get();
}
time = stopWatch.getTime();
System.out.println(time + " ms elapsed getting " + indices.size() + " requests");
}
示例4: testInsertUpdateQuotedStrings
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
@Test
public void testInsertUpdateQuotedStrings() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
this.sqlgGraph.tx().normalBatchModeOn();
for (int i = 0; i < 100; i++) {
this.sqlgGraph.addVertex(T.label, "Person", "name", "'a'");
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
this.sqlgGraph.tx().normalBatchModeOn();
List<Vertex> vertices = this.sqlgGraph.traversal().V().toList();
for (Vertex v : vertices) {
v.property("name", "'b'");
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
}
示例5: testHsqldbLargeLoad
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
@Test
public void testHsqldbLargeLoad() {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
for (int i = 1; i < 1000001; i++) {
Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "name", "John" + i);
Vertex dog = this.sqlgGraph.addVertex(T.label, "Dog", "name", "snowy" + i);
person.addEdge("pet", dog);
if (i % 100000 == 0) {
this.sqlgGraph.tx().commit();
}
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println("Time to insert: " + stopWatch.toString());
stopWatch.reset();
stopWatch.start();
Assert.assertEquals(1000000, this.sqlgGraph.traversal().V().<Vertex>has(T.label, "Person").count().next().intValue());
Assert.assertEquals(1000000, this.sqlgGraph.traversal().V().<Vertex>has(T.label, "Dog").count().next().intValue());
stopWatch.stop();
System.out.println("Time to read all vertices: " + stopWatch.toString());
}
示例6: timerTests
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
private static void timerTests(final CellBlockBuilder builder, final int count, final int size,
final Codec codec, final CompressionCodec compressor) throws IOException {
final int cycles = 1000;
StopWatch timer = new StopWatch();
timer.start();
for (int i = 0; i < cycles; i++) {
timerTest(builder, timer, count, size, codec, compressor, false);
}
timer.stop();
LOG.info("Codec=" + codec + ", compression=" + compressor + ", sized=" + false + ", count="
+ count + ", size=" + size + ", + took=" + timer.getTime() + "ms");
timer.reset();
timer.start();
for (int i = 0; i < cycles; i++) {
timerTest(builder, timer, count, size, codec, compressor, true);
}
timer.stop();
LOG.info("Codec=" + codec + ", compression=" + compressor + ", sized=" + true + ", count="
+ count + ", size=" + size + ", + took=" + timer.getTime() + "ms");
}
示例7: create
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
/**
* Create database schema for tenant.
*
* @param tenant - the tenant
*/
public void create(Tenant tenant) {
final StopWatch stopWatch = createStarted();
final String tenantKey = tenant.getTenantKey();
log.info("START - SETUP:CreateTenant:schema tenantKey: {}", tenantKey);
DatabaseUtil.createSchema(dataSource, tenantKey);
log.info("STOP - SETUP:CreateTenant:schema tenantKey: {}, time = {} ms", tenantKey,
stopWatch.getTime());
try {
stopWatch.reset();
stopWatch.start();
log.info("START - SETUP:CreateTenant:liquibase tenantKey: {}", tenantKey);
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setResourceLoader(resourceLoader);
liquibase.setDataSource(dataSource);
liquibase.setChangeLog(CHANGE_LOG_PATH);
liquibase.setContexts(liquibaseProperties.getContexts());
liquibase.setDefaultSchema(tenantKey);
liquibase.setDropFirst(liquibaseProperties.isDropFirst());
liquibase.setShouldRun(true);
liquibase.afterPropertiesSet();
log.info("STOP - SETUP:CreateTenant:liquibase tenantKey: {}, result: OK, time = {} ms", tenantKey,
stopWatch.getTime());
} catch (LiquibaseException e) {
log.info("STOP - SETUP:CreateTenant:liquibase tenantKey: {}, result: FAIL, error: {}, time = {} ms",
tenantKey, e.getMessage(), stopWatch.getTime());
throw new RuntimeException("Can not migrate database for creation tenant " + tenantKey, e);
}
}
示例8: test3DES
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Test
public void test3DES() {
StopWatch watch = new StopWatch();
watch.start();
String encodeText = EncryptUtils.encodeBy3DES(TEST_PLAIN_TEXT, TEST_PASSWORD);
watch.stop();
System.out.printf("%d\tms: 3DES(%s)\n", watch.getTime(), encodeText);
String decodeText = EncryptUtils.decodeBy3DES(encodeText, TEST_PASSWORD);
assertEquals(TEST_PLAIN_TEXT, decodeText);
decodeText = EncryptUtils.decodeBy3DES(encodeText, TEST_PASSWORD);
assertEquals(TEST_PLAIN_TEXT, decodeText);
watch.reset();
watch.start();
encodeText = EncryptUtils.encodeBy3DESAndBase64(TEST_PLAIN_TEXT, TEST_PASSWORD);
watch.stop();
System.out.printf("%d\tms: 3DES(%s)\n", watch.getTime(), encodeText);
decodeText = EncryptUtils.decodeBy3DESAndBase64(encodeText, TEST_PASSWORD);
assertEquals(TEST_PLAIN_TEXT, decodeText);
decodeText = EncryptUtils.decodeBy3DESAndBase64(encodeText, TEST_PASSWORD);
assertEquals(TEST_PLAIN_TEXT, decodeText);
}
示例9: getUniqueEntriesUsingDN
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
/**
* Put all entries from target into a map and then loop through all entries in
* source, check if the entry from source exists in the target map based on
* DN, if it doesn't write it to a file.
* @param source
* @param target
* @param ldifWriterUnique
*/
private void getUniqueEntriesUsingDN(Set<Entry> source, Set<Entry> target, LDIFWriter ldifWriterUnique, boolean sourceIsRightFile) {
Runnable r = () -> {
StopWatch sw = new StopWatch();
sw.start();
ConcurrentMap<String, Entry> targetMap = target.parallelStream().collect(Collectors.toConcurrentMap(Entry::getDN, Function.identity()));
for (Entry e : source) {
String dn = e.getDN();
if (!targetMap.containsKey(dn)) {
try {
ldifWriterUnique.writeEntry(e);//Entry only exists in rightLdif
if (sourceIsRightFile && generateDeleteLdifForMissingEntries) {
writeChangetypeDeleteRecord(dn);
}
} catch (IOException ex) {
logger.error("Error writing to LDIF file", ex);
}
}
}
fileWriteCdl.countDown();
sw.stop();
logger.info("Time taken to process getUniqueEntriesUsingDN(): " + sw.toString());
sw.reset();
};
exec.execute(r);
}
示例10: call
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
@Override
public OperationResult call() {
LOG.info("Random read: n={}", n);
final ObjectKeys objectKeys;
if (keyFileName == null) {
objectKeys = new S3ObjectKeysDataProvider(s3Client, bucket).get();
} else {
objectKeys = new SingletonFileObjectKeysDataProvider(keyFileName).get();
}
StopWatch stopWatch = new StopWatch();
for (int i = 0; i < n; i++) {
final String randomKey = objectKeys.getRandom();
LOG.debug("Read object: {}", randomKey);
stopWatch.reset();
stopWatch.start();
ObjectMetadata objectMetadata = s3Client.getObjectMetadata(bucket, randomKey);
LOG.debug("Object version: {}", objectMetadata.getVersionId());
stopWatch.stop();
LOG.debug("Time = {} ms", stopWatch.getTime());
getStats().addValue(stopWatch.getTime());
if (i > 0 && i % 1000 == 0) {
LOG.info("Progress: {} of {}", i, n);
}
}
return new OperationResult(getStats());
}
示例11: call
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
@Override
public OperationResult call() {
LOG.info("Random read: n={}", n);
final ObjectKeys objectKeys;
if (keyFileName == null) {
objectKeys = new S3ObjectKeysDataProvider(s3Client, bucket).get();
} else {
objectKeys = new SingletonFileObjectKeysDataProvider(keyFileName).get();
}
StopWatch stopWatch = new StopWatch();
for (int i = 0; i < n; i++) {
final String randomKey = objectKeys.getRandom();
LOG.debug("Read object: {}", randomKey);
stopWatch.reset();
stopWatch.start();
S3Object object = s3Client.getObject(bucket, randomKey);
try {
object.close();
} catch (IOException e) {
LOG.warn("An exception occurred while trying to close object with key: {}", randomKey);
}
stopWatch.stop();
LOG.debug("Time = {} ms", stopWatch.getTime());
getStats().addValue(stopWatch.getTime());
if (i > 0 && i % 1000 == 0) {
LOG.info("Progress: {} of {}", i, n);
}
}
return new OperationResult(getStats());
}
示例12: testBulkWithinVertexCompileStep
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
@Test
public void testBulkWithinVertexCompileStep() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
if (this.sqlgGraph.getSqlDialect().supportsBatchMode()) {
this.sqlgGraph.tx().normalBatchModeOn();
}
Vertex god = this.sqlgGraph.addVertex(T.label, "God");
List<String> uuids = new ArrayList<>();
for (int i = 0; i < 100; i++) {
String uuid = UUID.randomUUID().toString();
uuids.add(uuid);
Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", uuid);
god.addEdge("creator", person);
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
testBulkWithinVertexCompileStep_assert(this.sqlgGraph, god, uuids);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testBulkWithinVertexCompileStep_assert(this.sqlgGraph1, god, uuids);
}
stopWatch.stop();
System.out.println(stopWatch.toString());
}
示例13: testBulkWithinWithPercentageInJoinProperties
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
@Test
public void testBulkWithinWithPercentageInJoinProperties() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
if (this.sqlgGraph.getSqlDialect().supportsBatchMode()) {
this.sqlgGraph.tx().normalBatchModeOn();
}
Vertex god = this.sqlgGraph.addVertex(T.label, "God");
List<String> uuids = new ArrayList<>();
for (int i = 0; i < 100; i++) {
String uuid = UUID.randomUUID().toString();
uuids.add("\"BLRNC5->CXC4030052~%%%~FAJ1211373~%%%~2015-07-19~%%%~9999-12-31~%%%~Enabled~%%%~Licensed~%%%~Improved~%%%~compressed~%%%~mode~%%%~handling.~%%%~Restricted:~%%%~\"\"Partial.~%%%~Feature~%%%~is~%%%~restricted~%%%~in~%%%~RNC~%%%~W12B~%%%~SW.~%%%~RNC~%%%~W13.0.1.1~%%%~or~%%%~later~%%%~SW~%%%~is~%%%~required~%%%~in~%%%~order~%%%~to~%%%~run~%%%~this~%%%~feature.~%%%~For~%%%~RBS~%%%~W12.1.2.2/~%%%~W13.0.0.0~%%%~or~%%%~later~%%%~is~%%%~required.~%%%~OSS-RC~%%%~12.2~%%%~or~%%%~later~%%%~is~%%%~required.\"\".~%%%~GA:~%%%~W13A\"" + uuid);
Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", "\"BLRNC5->CXC4030052~%%%~FAJ1211373~%%%~2015-07-19~%%%~9999-12-31~%%%~Enabled~%%%~Licensed~%%%~Improved~%%%~compressed~%%%~mode~%%%~handling.~%%%~Restricted:~%%%~\"\"Partial.~%%%~Feature~%%%~is~%%%~restricted~%%%~in~%%%~RNC~%%%~W12B~%%%~SW.~%%%~RNC~%%%~W13.0.1.1~%%%~or~%%%~later~%%%~SW~%%%~is~%%%~required~%%%~in~%%%~order~%%%~to~%%%~run~%%%~this~%%%~feature.~%%%~For~%%%~RBS~%%%~W12.1.2.2/~%%%~W13.0.0.0~%%%~or~%%%~later~%%%~is~%%%~required.~%%%~OSS-RC~%%%~12.2~%%%~or~%%%~later~%%%~is~%%%~required.\"\".~%%%~GA:~%%%~W13A\"" + uuid);
god.addEdge("creator", person);
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
testBulkWithinWithPercentageInJoinProperties_assert(this.sqlgGraph, uuids);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testBulkWithinWithPercentageInJoinProperties_assert(this.sqlgGraph1, uuids);
}
stopWatch.stop();
System.out.println(stopWatch.toString());
}
示例14: testBulkWithout
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
@Test
public void testBulkWithout() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
if (this.sqlgGraph.getSqlDialect().supportsBatchMode()) {
this.sqlgGraph.tx().normalBatchModeOn();
}
Vertex god = this.sqlgGraph.addVertex(T.label, "God");
List<String> uuids = new ArrayList<>();
for (int i = 0; i < 100; i++) {
String uuid = UUID.randomUUID().toString();
uuids.add(uuid);
Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", uuid);
god.addEdge("creator", person);
}
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
testBulkWithout_assert(this.sqlgGraph, uuids);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testBulkWithout_assert(this.sqlgGraph1, uuids);
}
stopWatch.stop();
System.out.println(stopWatch.toString());
}
示例15: testBulkWithinMultipleHasContainers
import org.apache.commons.lang3.time.StopWatch; //導入方法依賴的package包/類
@Test
public void testBulkWithinMultipleHasContainers() throws InterruptedException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
Vertex god = this.sqlgGraph.addVertex(T.label, "God");
Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 1, "name", "pete");
god.addEdge("creator", person1);
Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 2, "name", "pete");
god.addEdge("creator", person2);
Vertex person3 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 3, "name", "john");
god.addEdge("creator", person3);
Vertex person4 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 4, "name", "pete");
god.addEdge("creator", person4);
Vertex person5 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 5, "name", "pete");
god.addEdge("creator", person5);
Vertex person6 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 6, "name", "pete");
god.addEdge("creator", person6);
Vertex person7 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 7, "name", "pete");
god.addEdge("creator", person7);
Vertex person8 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 8, "name", "pete");
god.addEdge("creator", person8);
Vertex person9 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 9, "name", "pete");
god.addEdge("creator", person9);
Vertex person10 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 10, "name", "pete");
god.addEdge("creator", person10);
this.sqlgGraph.tx().commit();
stopWatch.stop();
System.out.println(stopWatch.toString());
stopWatch.reset();
stopWatch.start();
testBulkWithinMultipleHasContainers_assert(this.sqlgGraph);
if (this.sqlgGraph1 != null) {
Thread.sleep(SLEEP_TIME);
testBulkWithinMultipleHasContainers_assert(this.sqlgGraph1);
}
stopWatch.stop();
System.out.println(stopWatch.toString());
}