List of usage examples for org.springframework.util StopWatch getTotalTimeSeconds
public double getTotalTimeSeconds()
From source file:kymr.github.io.future.LoadTest.java
public static void main(String[] args) throws InterruptedException { ExecutorService es = Executors.newFixedThreadPool(100); RestTemplate rt = new RestTemplate(); String url = "http://localhost:8080/dr"; StopWatch main = new StopWatch(); main.start();/*w w w . j av a2s .c o m*/ for (int i = 0; i < 100; i++) { es.execute(() -> { int idx = counter.addAndGet(1); log.info("Thread {}", idx); StopWatch sw = new StopWatch(); sw.start(); rt.getForObject(url, String.class); sw.stop(); log.info("Elapsed: {} -> {}", idx, sw.getTotalTimeSeconds()); }); } es.shutdown(); es.awaitTermination(100, TimeUnit.SECONDS); main.stop(); log.info("Total: {}", main.getTotalTimeSeconds()); }
From source file:com.auditbucket.client.Importer.java
private static long endProcess(StopWatch watch, long rows) { watch.stop();//from w ww. ja v a 2 s . c om double mins = watch.getTotalTimeSeconds() / 60; logger.info("Processed {} rows in {} secs. rpm = {}", rows, f.format(watch.getTotalTimeSeconds()), f.format(rows / mins)); return rows; }
From source file:fi.helsinki.opintoni.integration.interceptor.LoggingInterceptor.java
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { StopWatch stopWatch = new StopWatch(); stopWatch.start();//from w ww . j a va 2 s. c o m ClientHttpResponse response = execution.execute(request, body); stopWatch.stop(); log.info("Response for {} took {} seconds", request.getURI(), stopWatch.getTotalTimeSeconds()); return response; }
From source file:com.baocy.tut3.Tut3Receiver.java
public void receive(String in, int receiver) throws InterruptedException { StopWatch watch = new StopWatch(); watch.start();/* w ww. j a v a 2 s . c o m*/ System.out.println("instance " + receiver + " [x] Received '" + in + "'"); doWork(in); watch.stop(); System.out.println("instance " + receiver + " [x] Done in " + watch.getTotalTimeSeconds() + "s"); }
From source file:com.baocy.tut2.Tut2Receiver.java
@RabbitHandler public void receive(String in) throws InterruptedException { StopWatch watch = new StopWatch(); watch.start();/*from w w w. j av a2 s . c o m*/ System.out.println("instance " + this.instance + " [x] Received '" + in + "'"); doWork(in); watch.stop(); System.out.println("instance " + this.instance + " [x] Done in " + watch.getTotalTimeSeconds() + "s"); }
From source file:com.persistent.cloudninja.scheduler.TenantDeletionTask.java
@Override public boolean execute() { boolean retval = true; try {/*from w w w . j a v a 2s . com*/ TenantDeletionQueue tntDeletionQueue = (TenantDeletionQueue) getWorkQueue(); String tenantId = tntDeletionQueue.dequeue(SchedulerSettings.MessageVisibilityTimeout); if (tenantId == null) { LOGGER.debug("Msg is null"); retval = false; } else { StopWatch watch = new StopWatch(); watch.start(); provisioningService.removeTenant(tenantId); LOGGER.debug("tenant deleted :" + tenantId); watch.stop(); taskCompletionDao.updateTaskCompletionDetails(watch.getTotalTimeSeconds(), "DeleteTenant", "Tenant Id " + tenantId + " is deleted."); } } catch (StorageException e) { retval = false; LOGGER.error(e.getMessage(), e); } return retval; }
From source file:org.jsmiparser.AbstractMibTestCase.java
protected SmiMib getMib() { // this is a rather ugly hack to mimic JUnit4 @BeforeClass, without // having to annotate all test methods: if (m_mib.get() == null || m_testClass.get() != getClass()) { try {//from w ww .j ava 2 s .c om SmiParser parser = createParser(); StopWatch stopWatch = new StopWatch(); stopWatch.start(); SmiMib mib = parser.parse(); stopWatch.stop(); m_log.info("Parsing time: " + stopWatch.getTotalTimeSeconds() + " s"); m_mib.set(mib); m_testClass.set(getClass()); } catch (Exception e) { throw new RuntimeException(e); } } return m_mib.get(); }
From source file:org.olegz.uuid.TimeBasedUUIDGeneratorTests.java
@Test public void performanceTestSynch() { StopWatch stopWatch = new StopWatch(); stopWatch.start();//from w w w . j a v a2s. com for (int i = 0; i < 1000000; i++) { TimeBasedUUIDGenerator.generateId(); } stopWatch.stop(); System.out.println("Generated 1000000 UUID (sync) via TimeBasedUUIDGenerator.generateId(): in " + stopWatch.getTotalTimeSeconds() + " seconds"); stopWatch = new StopWatch(); stopWatch.start(); for (int i = 0; i < 1000000; i++) { UUID.randomUUID(); } stopWatch.stop(); System.out.println("Generated 1000000 UUID (sync) via UUID.randomUUID(): in " + stopWatch.getTotalTimeSeconds() + " seconds"); }
From source file:com.persistent.cloudninja.scheduler.DeploymentMonitor.java
@Override public boolean execute() { boolean retVal = true; try {/*from www. java 2 s. c o m*/ StopWatch watch = new StopWatch(); watch.start(); StringBuffer roleInfo = getRoleInfoForDeployment(); parseRoleInfo(roleInfo); watch.stop(); taskCompletionDao.updateTaskCompletionDetails(watch.getTotalTimeSeconds(), "ProcessMonitorInstanceCount", ""); } catch (Exception e) { LOGGER.error(e.getMessage(), e); retVal = false; } return retVal; }
From source file:org.ngrinder.perftest.service.ConsoleManagerTest.java
@Test public void testConsoleManagerWhenExceedingLimit() { // Get all console int initialSize = manager.getAvailableConsoleSize(); SingleConsole availableConsole = null; for (int i = 1; i <= initialSize; i++) { availableConsole = manager.getAvailableConsole(ConsolePropertiesFactory.createEmptyConsoleProperties()); }//from w ww. ja v a 2s .c om final SingleConsole lastConsole = availableConsole; assertThat(manager.getAvailableConsoleSize(), is(0)); StopWatch elapseTime = new StopWatch(); elapseTime.start(); // Try to get more console, it will take time try { manager.getAvailableConsole(ConsolePropertiesFactory.createEmptyConsoleProperties()); fail("should throw Exception"); } catch (NGrinderRuntimeException e) { } elapseTime.stop(); assertThat(elapseTime.getTotalTimeSeconds(), lessThan(3000D)); // Let's try the case when console is returned back. Thread thread = new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(1000); manager.returnBackConsole("test", lastConsole); } catch (InterruptedException e) { } } }); elapseTime = new StopWatch(); elapseTime.start(); thread.start(); // Try to get more console, it will return console just after console is // returned back SingleConsole anotherConsole = manager .getAvailableConsole(ConsolePropertiesFactory.createEmptyConsoleProperties()); elapseTime.stop(); assertThat(elapseTime.getTotalTimeSeconds(), lessThan(3000D)); assertThat(manager.getAvailableConsoleSize(), is(0)); manager.returnBackConsole("test", anotherConsole); // return console again is always allowed manager.returnBackConsole("test", anotherConsole); ThreadUtils.sleep(2000); assertThat(manager.getAvailableConsoleSize(), is(1)); assertThat(manager.getConsoleInUse().size(), is(initialSize - 1)); }