Java Code Examples for org.springframework.util.StopWatch#getTotalTimeMillis()
The following examples show how to use
org.springframework.util.StopWatch#getTotalTimeMillis() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note File: AbstractHttpServer.java License: MIT License | 6 votes |
@Override public final void start() { synchronized (this.lifecycleMonitor) { if (!isRunning()) { String serverName = getClass().getSimpleName(); if (logger.isDebugEnabled()) { logger.debug("Starting " + serverName + "..."); } this.running = true; try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); startInternal(); long millis = stopWatch.getTotalTimeMillis(); if (logger.isDebugEnabled()) { logger.debug("Server started on port " + getPort() + "(" + millis + " millis)."); } } catch (Throwable ex) { throw new IllegalStateException(ex); } } } }
Example 2
Source Project: java-technology-stack File: AbstractHttpServer.java License: MIT License | 6 votes |
@Override public final void start() { synchronized (this.lifecycleMonitor) { if (!isRunning()) { String serverName = getClass().getSimpleName(); if (logger.isDebugEnabled()) { logger.debug("Starting " + serverName + "..."); } this.running = true; try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); startInternal(); long millis = stopWatch.getTotalTimeMillis(); if (logger.isDebugEnabled()) { logger.debug("Server started on port " + getPort() + "(" + millis + " millis)."); } } catch (Throwable ex) { throw new IllegalStateException(ex); } } } }
Example 3
Source Project: java-microservice File: CallMonitoringAspect.java License: MIT License | 6 votes |
@Around("@annotation(com.apssouza.monitoring.Monitored)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { System.out.println("callend"); Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); if (this.enabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); try { return joinPoint.proceed(); } finally { sw.stop(); synchronized (this) { this.callCount++; this.accumulatedCallTime += sw.getTotalTimeMillis(); } publisher.publishEvent(new MonitoringInvokedEvent( method.getName(), this.accumulatedCallTime )); } } else { return joinPoint.proceed(); } }
Example 4
Source Project: DevOps-for-Web-Development File: CallMonitoringAspect.java License: MIT License | 6 votes |
@Around("within(@org.springframework.stereotype.Repository *)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { if (this.enabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); try { return joinPoint.proceed(); } finally { sw.stop(); synchronized (this) { this.callCount++; this.accumulatedCallTime += sw.getTotalTimeMillis(); } } } else { return joinPoint.proceed(); } }
Example 5
Source Project: DevOps-for-Web-Development File: CallMonitoringAspect.java License: MIT License | 6 votes |
@Around("within(@org.springframework.stereotype.Repository *)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { if (this.enabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); try { return joinPoint.proceed(); } finally { sw.stop(); synchronized (this) { this.callCount++; this.accumulatedCallTime += sw.getTotalTimeMillis(); } } } else { return joinPoint.proceed(); } }
Example 6
Source Project: spring-cloud-gateway File: AbstractHttpServer.java License: Apache License 2.0 | 6 votes |
@Override public final void start() { synchronized (this.lifecycleMonitor) { if (!isRunning()) { String serverName = getClass().getSimpleName(); if (logger.isDebugEnabled()) { logger.debug("Starting " + serverName + "..."); } this.running = true; try { StopWatch stopWatch = new StopWatch(); stopWatch.start(); startInternal(); long millis = stopWatch.getTotalTimeMillis(); if (logger.isDebugEnabled()) { logger.debug("Server started on port " + getPort() + "(" + millis + " millis)."); } } catch (Throwable ex) { throw new IllegalStateException(ex); } } } }
Example 7
Source Project: cacheonix-core File: CallMonitoringAspect.java License: GNU Lesser General Public License v2.1 | 6 votes |
@Around("within(@org.springframework.stereotype.Service *)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { if (this.isEnabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); try { return joinPoint.proceed(); } finally { sw.stop(); synchronized (this) { this.callCount++; this.accumulatedCallTime += sw.getTotalTimeMillis(); } } } else { return joinPoint.proceed(); } }
Example 8
Source Project: docker-workflow-plugin File: CallMonitoringAspect.java License: MIT License | 6 votes |
@Around("within(@org.springframework.stereotype.Repository *)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { if (this.enabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); try { return joinPoint.proceed(); } finally { sw.stop(); synchronized (this) { this.callCount++; this.accumulatedCallTime += sw.getTotalTimeMillis(); } } } else { return joinPoint.proceed(); } }
Example 9
Source Project: audit4j-demo File: CallMonitoringAspect.java License: Apache License 2.0 | 6 votes |
@Around("within(@org.springframework.stereotype.Repository *)") public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { if (this.enabled) { StopWatch sw = new StopWatch(joinPoint.toShortString()); sw.start("invoke"); try { return joinPoint.proceed(); } finally { sw.stop(); synchronized (this) { this.callCount++; this.accumulatedCallTime += sw.getTotalTimeMillis(); } } } else { return joinPoint.proceed(); } }
Example 10
Source Project: jhipster File: AsyncSpringLiquibase.java License: Apache License 2.0 | 5 votes |
/** * <p>initDb.</p> * * @throws liquibase.exception.LiquibaseException if any. */ protected void initDb() throws LiquibaseException { StopWatch watch = new StopWatch(); watch.start(); super.afterPropertiesSet(); watch.stop(); logger.debug(STARTED_MESSAGE, watch.getTotalTimeMillis()); if (watch.getTotalTimeMillis() > SLOWNESS_THRESHOLD * 1000L) { logger.warn(SLOWNESS_MESSAGE, SLOWNESS_THRESHOLD); } }
Example 11
Source Project: spring-boot-rxjava File: GithubServiceTest.java License: Apache License 2.0 | 5 votes |
@Test public void testGetUser() throws Exception { StopWatch stopwatch = new StopWatch(); stopwatch.start(); GithubUser foo = githubService.getUser("foo"); stopwatch.stop(); long duration = stopwatch.getTotalTimeMillis(); assertThat(foo).isNotNull(); assertThat(foo.getUser()).isNotNull(); assertThat(foo.getUser().getLogin()).isEqualTo("foo"); assertThat(foo.getUser().getName()).isEqualTo("foo bar"); assertThat(foo.getFollowers()) .hasSize(3) .extracting("name") .contains("bar", "qix", "baz"); assertThat(foo.getRepositories()) .hasSize(2) .extracting("name") .contains("foo", "bar"); // duration should be at least 300ms & max 400ms with overhead assertThat(duration).isGreaterThanOrEqualTo(300); assertThat(duration).isLessThanOrEqualTo(400); }
Example 12
Source Project: spring-analysis-note File: AspectJAutoProxyCreatorTests.java License: MIT License | 4 votes |
private void assertStopWatchTimeLimit(final StopWatch sw, final long maxTimeMillis) { long totalTimeMillis = sw.getTotalTimeMillis(); assertTrue("'" + sw.getLastTaskName() + "' took too long: expected less than<" + maxTimeMillis + "> ms, actual<" + totalTimeMillis + "> ms.", totalTimeMillis < maxTimeMillis); }
Example 13
Source Project: java-technology-stack File: AspectJAutoProxyCreatorTests.java License: MIT License | 4 votes |
private void assertStopWatchTimeLimit(final StopWatch sw, final long maxTimeMillis) { long totalTimeMillis = sw.getTotalTimeMillis(); assertTrue("'" + sw.getLastTaskName() + "' took too long: expected less than<" + maxTimeMillis + "> ms, actual<" + totalTimeMillis + "> ms.", totalTimeMillis < maxTimeMillis); }
Example 14
Source Project: hentai File: LoggingAspect.java License: Apache License 2.0 | 4 votes |
private String createTimerString(StopWatch stopWatch) { long millis = stopWatch.getTotalTimeMillis(); return format(" [%d ms]", millis); }
Example 15
Source Project: spring4-understanding File: AspectJAutoProxyCreatorTests.java License: Apache License 2.0 | 4 votes |
private static void assertStopWatchTimeLimit(final StopWatch sw, final long maxTimeMillis) { final long totalTimeMillis = sw.getTotalTimeMillis(); assertTrue("'" + sw.getLastTaskName() + "' took too long: expected less than<" + maxTimeMillis + "> ms, actual<" + totalTimeMillis + "> ms.", totalTimeMillis < maxTimeMillis); }