org.infinispan.commons.util.Util.prettyPrintTime()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中org.infinispan.commons.util.Util.prettyPrintTime()方法的一些代码示例,展示了Util.prettyPrintTime()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.prettyPrintTime()方法的具体详情如下:
包路径:org.infinispan.commons.util.Util
类名称:Util
方法名:prettyPrintTime

Util.prettyPrintTime介绍

[英]Prints a time for display
[中]打印显示时间

代码示例

代码示例来源:origin: org.infinispan/infinispan-commons

public static String prettyPrintTime(long time, TimeUnit unit) {
 return prettyPrintTime(unit.toMillis(time));
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testSpeed() {
 int[] numNodes = {1, 2, 3, 4, 10, 100, 1000};
 int iterations = 100000;
 // warmup
 doPerfTest(10, 2, iterations);
 for (int numOwners = 1; numOwners < 5; numOwners++) {
   System.out.println("numOwners=" + numOwners);
   for (int nn: numNodes) {
    Long duration = doPerfTest(nn, numOwners, iterations);
    System.out.println("With "+nn+" cache(s), time to do " + iterations + " lookups was " + Util.prettyPrintTime(TimeUnit.NANOSECONDS.toMillis(duration)));
   }
 }
}

代码示例来源:origin: org.infinispan/infinispan-query

/**
* We write a lot of elements.. and run a Query occasionally to check.
*/
private void writeStuff(final Cache<Object, Object> cache) {
 final long startTime = System.nanoTime();
 for (int i = 1; i < TOTAL_LOOPS; i++) {
   final String key = "K" + i;
   final Person value = new Person(key, key, i);
   cache.put(key, value);
   if (i % QUERY_PERIODICITY == 0) {
    countElementsViaQuery(cache, i);
   }
   if (i % TIMESAMPLE_PERIODICITY == 0) {
    final long currentTimeStamp = System.nanoTime();
    final long elapsed = currentTimeStamp - startTime;
    final double elementsWrittenPerSecond = ((double)TimeUnit.NANOSECONDS.convert(i, TimeUnit.SECONDS))/elapsed;
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMaximumFractionDigits(2);
    nf.setGroupingUsed(true);
    System.out.println(
       "Transactions committed to index per second: " + nf.format(elementsWrittenPerSecond) +
       ". Total documents: " + i +
       " Total time: " + Util.prettyPrintTime(elapsed, TimeUnit.NANOSECONDS)
       );
   }
 }
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testIndexing() throws Exception {
 int carId = 0;
 int cacheId = 0;
 final long start = System.nanoTime();
 for (int outherLoop = 0; outherLoop < NUMBER_OF_ITERATIONS; outherLoop++) {
   final Cache<String, Car> cache = getWriteOnlyCache(cacheId++ % NUM_NODES);
   System.out.print("Using " + cacheId + ": " + cache +"\t");
   final long blockStart = System.nanoTime();
   cache.startBatch();
   for (int innerLoop = 0; innerLoop < LOG_ON_EACH; innerLoop++) {
    carId++;
    cache.put("car" + carId, new Car("megane", "blue", 300 + carId));
    carId++;
    cache.put("car" + carId, new Car("bmw", "blue", 300 + carId));
   }
   cache.endBatch(true);
   System.out.println("Inserted " + LOG_ON_EACH + " cars in " + Util.prettyPrintTime(System.nanoTime() - blockStart, TimeUnit.NANOSECONDS));
 }
 System.out.println("Test took " + Util.prettyPrintTime(System.nanoTime() - start, TimeUnit.NANOSECONDS));
 verifyFindsCar(carId / 2, "megane");
}

代码示例来源:origin: org.infinispan/infinispan-core

@InTransactionMode(TransactionMode.TRANSACTIONAL)
  public void testLeaveDuringGetTransactions() throws InterruptedException, TimeoutException {
   final CheckPoint checkpoint = new CheckPoint();
   StateProvider stateProvider = TestingUtil.extractComponent(c2, StateProvider.class);
   StateProvider spyStateProvider = spy(stateProvider);
   doAnswer(invocation -> {
     int topologyId = (Integer) invocation.getArguments()[1];
     checkpoint.trigger("GET_TRANSACTIONS");
     log.debugf("Blocking the GET_TRANSACTIONS(%d) command on the %s", topologyId, c2);
     checkpoint.awaitStrict("LEAVE", 10, TimeUnit.SECONDS);
     return invocation.callRealMethod();
   }).when(spyStateProvider).getTransactionsForSegments(any(Address.class), anyInt(), any());
   TestingUtil.replaceComponent(c2, StateProvider.class, spyStateProvider, true);

   long startTime = System.currentTimeMillis();
   manager(2).stop();

   checkpoint.awaitStrict("GET_TRANSACTIONS", 10, TimeUnit.SECONDS);
   manager(1).stop();
   checkpoint.trigger("LEAVE");

   TestingUtil.blockUntilViewsReceived(30000, false, c1);
   TestingUtil.waitForNoRebalance(c1);
   long endTime = System.currentTimeMillis();
   log.debugf("Recovery took %s", Util.prettyPrintTime(endTime - startTime));
   assert endTime - startTime < 30000 : "Recovery took too long: " + Util.prettyPrintTime(endTime - startTime);
  }
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testClusterRecoveryAfterCoordLeave() throws Exception {
 // create the partitions
 log.debugf("Killing coordinator via discard");
 d1.setDiscardAll(true);
 // wait for the partitions to form
 long startTime = System.currentTimeMillis();
 TestingUtil.blockUntilViewsReceived(30000, false, c1);
 TestingUtil.blockUntilViewsReceived(30000, false, c2, c3);
 TestingUtil.waitForNoRebalance(c1);
 TestingUtil.waitForNoRebalance(c2, c3);
 long endTime = System.currentTimeMillis();
 log.debugf("Recovery took %s", Util.prettyPrintTime(endTime - startTime));
 assert endTime - startTime < 30000 : "Recovery took too long: " + Util.prettyPrintTime(endTime - startTime);
 // Check that a new node can join
 addClusterEnabledCacheManager(defaultConfig, new TransportFlags().withFD(true).withMerge(true));
 Cache<Object, Object> c4 = cache(3, CACHE_NAME);
 TestingUtil.blockUntilViewsReceived(30000, true, c2, c3, c4);
 TestingUtil.waitForNoRebalance(c2, c3, c4);
}

代码示例来源:origin: org.infinispan/infinispan-core

System.out.printf("%s %s %s %s%n",
    padString(f.getClass().getSimpleName(), 25),
    padString(prettyPrintTime(sRes), 18),
    padString(prettyPrintTime(bRes), 18),
    padString(prettyPrintTime(oRes), 18)
);
System.out.printf("%s %s %s %s%n",

代码示例来源:origin: org.infinispan/infinispan-core

log.debugf("Merge took %s", Util.prettyPrintTime(endTime - startTime));
assert endTime - startTime < 30000 : "Merge took too long: " + Util.prettyPrintTime(endTime - startTime);

代码示例来源:origin: org.infinispan/infinispan-core

log.debugf("Merge took %s", Util.prettyPrintTime(endTime - startTime));
assert endTime - startTime < 30000 : "Merge took too long: " + Util.prettyPrintTime(endTime - startTime);

代码示例来源:origin: org.infinispan/infinispan-core

log.debugf("Merge took %s", Util.prettyPrintTime(endTime - startTime));
assert endTime - startTime < 30000 : "Merge took too long: " + Util.prettyPrintTime(endTime - startTime);

代码示例来源:origin: org.infinispan/infinispan-core

log.debugf("Recovery took %s", Util.prettyPrintTime(endTime - startTime));
assert endTime - startTime < 30000 : "Recovery took too long: " + Util.prettyPrintTime(endTime - startTime);

相关文章