I\'m using a Java socket, connected to a server. If I send a HEADER http request, how can I measure the response time from the server? Must I use a provided java timer, or is t
@Aspect
@Profile("performance")
@Component
public class MethodsExecutionPerformance {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Pointcut("execution(* it.test.microservice.myService.service.*.*(..))")
public void serviceMethods() {
}
@Around("serviceMethods()")
public Object monitorPerformance(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
StopWatch stopWatch = new StopWatch(getClass().getName());
stopWatch.start();
Object output = proceedingJoinPoint.proceed();
stopWatch.stop();
logger.info("Method execution time\n{}", stopWatch.prettyPrint());
return output;
}
}
In this way, you can calculate the real response time of your service independent of network speed.