Now I am trying to integrate JMH benchmark into my microservice which is written in reactive java. I am using a controller method with many other services integrated as maven dependencies. I can't find any resources on to use @Benchmark
with asynchronous calls. Additionally, with many chained service classes within the controller, how does this work? My JUnit tests currently have a combination @MockBean
and Mockito.
I have started with the framework outlinerd here https://github.com/stsypanov/spring-boot-benchmark but not sure how to expand to reactive java. An example of the code I want to benchmark:
@RestController
@Validated
@RequiredArgsConstructor
@RequestMapping(value = "/api/v1/projects", produces = HAL_UTF8)
public class ProjectController {
private final ProjectService projectService; // interface with @Service annotation
public Mono<ResponseEntity<Void>> deleteProject(
@ApiParam(required = true, value = "Existing Project Directory URN") @PathVariable
String id) {
return projectService
.deleteProject(finalId)
.thenReturn(ResponseEntity.noContent().<Void>build());
}
}
I think for measuring this you could use JLBH (Java Latency Benchmark Harness) instead of JMH. See it's repository for details: https://github.com/OpenHFT/JLBH .
The pros of JLBH as opposed to JMH are:
For quick start-up guide please have a look into https://www.javacodegeeks.com/2016/04/jlbh-introducing-java-latency-benchmarking-harness.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.