Skip to content

Commit

Permalink
Refactor performance test after updates
Browse files Browse the repository at this point in the history
This replaces the deprecated method call and removes the raw type usage.
  • Loading branch information
MaisiKoleni committed Jul 28, 2023
1 parent 792f005 commit 5847733
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/test/java/net/maisikoleni/javadoc/server/PerformanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.random.RandomGeneratorFactory;
import java.util.stream.IntStream;
Expand All @@ -20,15 +17,10 @@

import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.vertx.core.CompositeFuture;
import io.vertx.core.Future;
import io.vertx.core.Vertx;
import io.vertx.core.VertxOptions;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientOptions;
import io.vertx.core.http.HttpClientRequest;
import io.vertx.core.http.HttpClientResponse;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.*;

@QuarkusTest
class PerformanceTest {
Expand Down Expand Up @@ -63,14 +55,13 @@ void setupHttpClient() {
void testSearchSuggestionPerformance() {
var queries = generateRandomQueries();

@SuppressWarnings("rawtypes") // needs to be raw type, sadly
var futureResponses = queries.stream().<Future>map(q -> {
var futureResponses = queries.stream().map(q -> {
String requestURI = "/api/v2/libraries/jdk-latest/search/suggestions?query="
+ URLEncoder.encode(q, StandardCharsets.UTF_8);
return client.request(HttpMethod.GET, requestURI).compose(req -> handleRequest(req, q));
}).toList();
// wait for requests to complete
CompositeFuture.join(futureResponses).toCompletionStage().toCompletableFuture().join();
Future.join(futureResponses).toCompletionStage().toCompletableFuture().join();
// create a summary statistic
var stats = timings.values().stream().flatMap(List::stream).mapToLong(x -> x).summaryStatistics();
LOG.info("Performance statistics: {}", stats);
Expand Down

0 comments on commit 5847733

Please sign in to comment.