You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2020/11/21 20:48:00 UTC

[httpcomponents-core] 02/05: Improved connection re-use (keep-alive) tracking by the benchmark; disabled H2 push when running the benchmark with HTTP/2

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch 5.0.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git

commit bf6114a2081593389c376f3e8068a75d4360ecd7
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Sat Nov 21 17:36:28 2020 +0100

    Improved connection re-use (keep-alive) tracking by the benchmark; disabled H2 push when running the benchmark with HTTP/2
---
 .../main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java   | 3 ++-
 .../src/main/java/org/apache/hc/core5/benchmark/HttpBenchmark.java | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
index 3d9698b..b92b914 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/BenchmarkWorker.java
@@ -163,7 +163,7 @@ class BenchmarkWorker implements ResourceHolder {
             public void failed(final Exception cause) {
                 stats.incFailureCount();
                 if (config.getVerbosity() >= 1) {
-                    System.out.println("Failed HTTP request : " + cause.getMessage());
+                    System.out.println("Failed HTTP request: " + cause.getMessage());
                 }
             }
 
@@ -326,6 +326,7 @@ class BenchmarkWorker implements ResourceHolder {
 
                 });
             } else {
+                stats.incKeepAliveCount();
                 endpoint.execute(
                         createRequestProducer(),
                         createResponseConsumer(),
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/HttpBenchmark.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/HttpBenchmark.java
index a14200c..f5b6e18 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/HttpBenchmark.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/HttpBenchmark.java
@@ -61,6 +61,7 @@ import org.apache.hc.core5.http.protocol.HttpProcessorBuilder;
 import org.apache.hc.core5.http.protocol.RequestExpectContinue;
 import org.apache.hc.core5.http.protocol.RequestUserAgent;
 import org.apache.hc.core5.http2.HttpVersionPolicy;
+import org.apache.hc.core5.http2.config.H2Config;
 import org.apache.hc.core5.http2.frame.FramePrinter;
 import org.apache.hc.core5.http2.frame.RawFrame;
 import org.apache.hc.core5.http2.impl.nio.H2StreamListener;
@@ -173,6 +174,9 @@ public class HttpBenchmark {
                 .setHttpProcessor(builder.build())
                 .setTlsStrategy(new BasicClientTlsStrategy(sslContext))
                 .setVersionPolicy(versionPolicy)
+                .setH2Config(H2Config.custom()
+                        .setPushEnabled(false)
+                        .build())
                 .setIOSessionDecorator(new Decorator<IOSession>() {
 
                     @Override
@@ -354,9 +358,6 @@ public class HttpBenchmark {
 
                     @Override
                     public void onExchangeComplete(final HttpConnection connection, final boolean keepAlive) {
-                        if (keepAlive) {
-                            stats.incKeepAliveCount();
-                        }
                     }
 
                 })