當前位置: 首頁>>代碼示例>>Java>>正文


Java StopWatch.stop方法代碼示例

本文整理匯總了Java中org.springframework.util.StopWatch.stop方法的典型用法代碼示例。如果您正苦於以下問題:Java StopWatch.stop方法的具體用法?Java StopWatch.stop怎麽用?Java StopWatch.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.util.StopWatch的用法示例。


在下文中一共展示了StopWatch.stop方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: invoke

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
@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();
    }
}
 
開發者ID:apssouza22,項目名稱:java-microservice,代碼行數:26,代碼來源:CallMonitoringAspect.java

示例2: responseEnd

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
@Override
public void responseEnd(StopWatch requestWatch, HttpServerResponse response) {
    requestWatch.stop();
    counterService.increment("responses.count.total");
    int statusCode = response.getStatusCode();
    long totalTimeMillis = requestWatch.getTotalTimeMillis();
    gaugeService.submit("responses.totalTime.all", totalTimeMillis);
    if (statusCode > 400) {
        gaugeService.submit("responses.totalTime.error.all", totalTimeMillis);
        counterService.increment("responses.count.error.total");
        if (statusCode > 500) {
            counterService.increment("responses.count.error.server");
            gaugeService.submit("responses.totalTime.error.server", totalTimeMillis);
        } else {
            counterService.increment("responses.count.error.client");
            gaugeService.submit("responses.totalTime.error.client", totalTimeMillis);
        }
    } else if (statusCode > 300) {
        counterService.increment("responses.count.redirect");
        gaugeService.submit("responses.totalTime.redirect", totalTimeMillis);
    } else if (statusCode > 200) {
        counterService.increment("responses.count.success");
        gaugeService.submit("responses.totalTime.success", totalTimeMillis);
    }
}
 
開發者ID:unbroken-dome,項目名稱:vertx-spring,代碼行數:26,代碼來源:VertxActuatorMetrics.java

示例3: watchPerformance

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
@Around("performance()")
public Object watchPerformance(ProceedingJoinPoint point){
    System.out.println("The service start:");
    StopWatch stopWatch = new StopWatch("performance");
    stopWatch.start(point.getSignature().toString());
    try {
        return point.proceed();
    } catch (Throwable throwable) {
        throwable.printStackTrace();
    }finally {
        stopWatch.stop();
        StopWatch.TaskInfo[] taskInfo = stopWatch.getTaskInfo();
        for (StopWatch.TaskInfo info : taskInfo) {
            System.out.println(info.getTaskName());
            System.out.println(info.getTimeMillis());
        }
        System.out.println("The "+point.getSignature().toString()+" run time:"+stopWatch.prettyPrint());
    }

    return null;
}
 
開發者ID:devpage,項目名稱:sharding-quickstart,代碼行數:22,代碼來源:PerformaceMonitor.java

示例4: doFilterInternal

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
@Override
protected void doFilterInternal(HttpServletRequest request,
		HttpServletResponse response, FilterChain chain)
				throws ServletException, IOException {
	StopWatch stopWatch = createStopWatchIfNecessary(request);
	String path = new UrlPathHelper().getPathWithinApplication(request);
	int status = HttpStatus.INTERNAL_SERVER_ERROR.value();
	try {
		chain.doFilter(request, response);
		status = getStatus(response);
	}
	finally {
		if (!request.isAsyncStarted()) {
			stopWatch.stop();
			request.removeAttribute(ATTRIBUTE_STOP_WATCH);
			recordMetrics(request, path, status, stopWatch.getTotalTimeMillis());
		}
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:20,代碼來源:MetricsFilter.java

示例5: testPrototypeCreationWithResourcePropertiesIsFastEnough

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
@Test
public void testPrototypeCreationWithResourcePropertiesIsFastEnough() {
	GenericApplicationContext ctx = new GenericApplicationContext();
	AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
	ctx.refresh();

	RootBeanDefinition rbd = new RootBeanDefinition(ResourceAnnotatedTestBean.class);
	rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
	ctx.registerBeanDefinition("test", rbd);
	ctx.registerBeanDefinition("spouse", new RootBeanDefinition(TestBean.class));
	TestBean spouse = (TestBean) ctx.getBean("spouse");
	StopWatch sw = new StopWatch();
	sw.start("prototype");
	for (int i = 0; i < 100000; i++) {
		TestBean tb = (TestBean) ctx.getBean("test");
		assertSame(spouse, tb.getSpouse());
	}
	sw.stop();
	assertTrue("Prototype creation took too long: " + sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 4000);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:21,代碼來源:AnnotationProcessorPerformanceTests.java

示例6: execute

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
@Override
public void execute(String tableName, MutatorCallback action) {
    Assert.notNull(action, "Callback object must not be null");
    Assert.notNull(tableName, "No table specified");

    StopWatch sw = new StopWatch();
    sw.start();
    String status = EventLog.MONITOR_STATUS_SUCCESS;
    BufferedMutator mutator = null;
    try {
        BufferedMutatorParams mutatorParams = new BufferedMutatorParams(TableName.valueOf(tableName));
        mutator = this.getConnection().getBufferedMutator(mutatorParams.writeBufferSize(3 * 1024 * 1024));
        action.doInMutator(mutator);
    } catch (Throwable throwable) {
        status = EventLog.MONITOR_STATUS_FAILED;
        throw new HbaseSystemException(throwable);
    } finally {
        if (null != mutator) {
            try {
                mutator.flush();
                mutator.close();
                sw.stop();
                LOGGER.info(EventLog.buildEventLog(EventType.middleware_opt, MiddleWare.HBASE.symbol(), sw.getTotalTimeMillis(), status, "hbase請求").toString());
            } catch (IOException e) {
                LOGGER.error("hbase mutator資源釋放失敗");
            }
        }
    }
}
 
開發者ID:JThink,項目名稱:SkyEye,代碼行數:30,代碼來源:HbaseTemplate.java

示例7: logExecutionTime

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
/**
 * We have annotated our method with @Around. This is our advice,
 * and around advice means we are adding extra code both before and after method execution.
 *
 * Our @Around annotation has a point cut argument. Our pointcut just says,
 * ‘Apply this advice any method which is annotated with @LogExecutionTime.’
 */
@Around("@annotation(gr.personal.group.aop.annotations.LogExecutionTime)")
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable{
    StopWatch stopWatch = new StopWatch(LogTimeExecutionAspect.class.getName());
    stopWatch.start(((MethodSignature) joinPoint.getSignature()).getMethod().getName());
    //Just call the annotated method (Join point)
    Object proceed = joinPoint.proceed();
    stopWatch.stop();
    logger.trace(stopWatch.prettyPrint());
    return proceed;
}
 
開發者ID:nicolasmanic,項目名稱:Facegram,代碼行數:18,代碼來源:LogTimeExecutionAspect.java

示例8: synchronizeAllUsersInfos

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
public void synchronizeAllUsersInfos() {
	log.info("Synchronize of all users called");
	StopWatch stopWatch = new StopWatch();
	stopWatch.start("Synchronize of all users");
	long nbUpdate = 0;
	long nbNoUpdate = 0;
	long nbError = 0;
	for(User user : User.findAllUsers()) {
		try {
			if(resynchronisationUserService.synchronizeUserInfo(user.getEppn())) {
				nbUpdate++;
			} else {
				nbNoUpdate++;
			}
		} catch(Exception ex) {
			log.error("Error during synchronize " + user.getEppn(), ex);
			 nbError++;
		}
		if(shutdownCalled) {
			log.warn("shutdown called during synchroization of all users - we stop it");
			break;
		}
		try {
			// on temporise un peu ... 
			Thread.currentThread().sleep(2);
		} catch (InterruptedException e) {
			//
		}
	}
	stopWatch.stop();
	log.debug(stopWatch.prettyPrint());
	log.info("Sync users in " + stopWatch.getTotalTimeMillis()/1000.0 + "sec - nb updated (needed) : " + nbUpdate + " - nb no updated (no need) : " + nbNoUpdate + " - errors : " + nbError);
}
 
開發者ID:EsupPortail,項目名稱:esup-sgc,代碼行數:34,代碼來源:ResynchronisationService.java

示例9: swaggerSpringfoxDocket

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
/**
 * Swagger Springfox configuration.
 */
@Bean
public Docket swaggerSpringfoxDocket(JHipsterProperties jHipsterProperties) {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    ApiInfo apiInfo = new ApiInfo(
        jHipsterProperties.getSwagger().getTitle(),
        jHipsterProperties.getSwagger().getDescription(),
        jHipsterProperties.getSwagger().getVersion(),
        jHipsterProperties.getSwagger().getTermsOfServiceUrl(),
        jHipsterProperties.getSwagger().getContact(),
        jHipsterProperties.getSwagger().getLicense(),
        jHipsterProperties.getSwagger().getLicenseUrl());

    Docket docket = new Docket(DocumentationType.SWAGGER_2)
        .apiInfo(apiInfo)
        .genericModelSubstitutes(ResponseEntity.class)
        .forCodeGeneration(true)
        .genericModelSubstitutes(ResponseEntity.class)
        .directModelSubstitute(java.time.LocalDate.class, String.class)
        .directModelSubstitute(java.time.ZonedDateTime.class, Date.class)
        .directModelSubstitute(java.time.LocalDateTime.class, Date.class)
        .select()
        .paths(regex(DEFAULT_INCLUDE_PATTERN))
        .build();
    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
}
 
開發者ID:GastonMauroDiaz,項目名稱:buenojo,代碼行數:33,代碼來源:SwaggerConfiguration.java

示例10: swaggerSpringfoxDocket

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
/**
 * Swagger Springfox configuration.
 *
 * @param jHipsterProperties the properties of the application
 * @return the Swagger Springfox configuration
 */
@Bean
public Docket swaggerSpringfoxDocket(JHipsterProperties jHipsterProperties) {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    Contact contact = new Contact(
        jHipsterProperties.getSwagger().getContactName(),
        jHipsterProperties.getSwagger().getContactUrl(),
        jHipsterProperties.getSwagger().getContactEmail());

    ApiInfo apiInfo = new ApiInfo(
        jHipsterProperties.getSwagger().getTitle(),
        jHipsterProperties.getSwagger().getDescription(),
        jHipsterProperties.getSwagger().getVersion(),
        jHipsterProperties.getSwagger().getTermsOfServiceUrl(),
        contact,
        jHipsterProperties.getSwagger().getLicense(),
        jHipsterProperties.getSwagger().getLicenseUrl());

    Docket docket = new Docket(DocumentationType.SWAGGER_2)
        .apiInfo(apiInfo)
        .forCodeGeneration(true)
        .genericModelSubstitutes(ResponseEntity.class)
        .select()
        .paths(regex(DEFAULT_INCLUDE_PATTERN))
        .build();
    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
}
 
開發者ID:quanticc,項目名稱:sentry,代碼行數:37,代碼來源:SwaggerConfiguration.java

示例11: loadAllMetrics

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
private void loadAllMetrics() {

        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        log.info("Loading all metric names from db...");
        int totalMetrics = 0;


        for (int level = 1; ; level++) {
            log.info("Loading metrics for level " + level);
            final AtomicInteger levelCount = new AtomicInteger(0);
            clickHouseJdbcTemplate.query(
                "SELECT name, argMax(status, updated) as last_status " +
                    "FROM " + metricsTable + " PREWHERE level = ? WHERE status != ? GROUP BY name",
                new MetricRowCallbackHandler(levelCount),
                level, MetricStatus.AUTO_HIDDEN.name()
            );

            if (levelCount.get() == 0) {
                log.info("No metrics on level " + level + " loading complete");
                break;
            }
            totalMetrics += levelCount.get();
            log.info("Loaded " + levelCount.get() + " metrics for level " + level);

            if (inMemoryLevelsCount > 0 && level == inMemoryLevelsCount) {
                log.info("Loaded first all " + inMemoryLevelsCount + " in memory levels of metric tree");
                break;
            }
        }
        stopWatch.stop();
        log.info(
            "Loaded complete. Total " + totalMetrics + " metrics in " + stopWatch.getTotalTimeSeconds() + " seconds"
        );
    }
 
開發者ID:yandex,項目名稱:graphouse,代碼行數:36,代碼來源:MetricSearch.java

示例12: end

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
@Override
public void end(StopWatch stopWatch, boolean succeeded) {
    stopWatch.stop();
    if (succeeded) {
        counterService.increment("tasks.succeeded");
    } else {
        counterService.increment("tasks.failed");
    }
    gaugeService.submit("tasks.durationMs", stopWatch.getLastTaskTimeMillis());
}
 
開發者ID:unbroken-dome,項目名稱:vertx-spring,代碼行數:11,代碼來源:VertxActuatorMetrics.java

示例13: upgrade

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
@Override
public StopWatch upgrade(StopWatch requestWatch, ServerWebSocket serverWebSocket) {
    requestWatch.stop();
    counterService.increment("requests.upgraded");
    requestWatch.start("websocket");
    return requestWatch;
}
 
開發者ID:unbroken-dome,項目名稱:vertx-spring,代碼行數:8,代碼來源:VertxActuatorMetrics.java

示例14: printBackFromErrorStateInfoIfStopWatchIsRunning

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
private static void printBackFromErrorStateInfoIfStopWatchIsRunning(StopWatch stopWatch) {

		if (stopWatch.isRunning()) {
			stopWatch.stop();
			System.err.println("INFO: Recovered after: " + stopWatch.getLastTaskInfo().getTimeSeconds());
		}
	}
 
開發者ID:Just-Fun,項目名稱:spring-data-examples,代碼行數:8,代碼來源:RedisSentinelApplication.java

示例15: afterCompletion

import org.springframework.util.StopWatch; //導入方法依賴的package包/類
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) throws Exception {
    StopWatch stopWatch = stopWatchLocal.get();
    stopWatch.stop();
    logger.info("Łączny czas przetwarzania żądania: " + stopWatch.getTotalTimeMillis()+ " ms");
    stopWatchLocal.set(null);
    logger.info("=======================================================");
}
 
開發者ID:TomirKlos,項目名稱:Webstore,代碼行數:8,代碼來源:PerformanceMonitorInterceptor.java


注:本文中的org.springframework.util.StopWatch.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。