Skip to content

Commit 24b7801

Browse files
JonathanHensonrccarper
authored andcommitted
Fixed benchmark builds.
1 parent 1681407 commit 24b7801

File tree

3 files changed

+107
-5
lines changed

3 files changed

+107
-5
lines changed

http-clients/aws-crt-client/src/main/java/software/amazon/awssdk/http/crt/internal/AwsCrtAsyncHttpStreamAdapter.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ public int onResponseBody(HttpStream stream, byte[] bodyBytesIn) {
100100
respBodyPublisher.queueBuffer(bodyBytesIn);
101101
respBodyPublisher.publishToSubscribers();
102102

103-
if (bodyBytesIn.length != 0) {
104-
throw new IllegalStateException("Unprocessed bytes remain in bodyBytesIn Buffer!");
105-
}
106-
107103
return 0;
108104
}
109105

test/sdk-benchmarks/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
<dependency>
194194
<groupId>software.amazon.awssdk.crt</groupId>
195195
<artifactId>aws-crt</artifactId>
196-
<version>0.3.35</version>
196+
<version>0.4.1</version>
197197
<scope>compile</scope>
198198
</dependency>
199199
<dependency>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.benchmark.apicall.httpclient.async;
17+
18+
import org.openjdk.jmh.annotations.*;
19+
import org.openjdk.jmh.infra.Blackhole;
20+
import org.openjdk.jmh.profile.StackProfiler;
21+
import org.openjdk.jmh.results.RunResult;
22+
import org.openjdk.jmh.runner.Runner;
23+
import org.openjdk.jmh.runner.options.Options;
24+
import org.openjdk.jmh.runner.options.OptionsBuilder;
25+
import software.amazon.awssdk.benchmark.apicall.httpclient.SdkHttpClientBenchmark;
26+
import software.amazon.awssdk.benchmark.utils.MockServer;
27+
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
28+
import software.amazon.awssdk.http.crt.AwsCrtAsyncHttpClient;
29+
import software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonAsyncClient;
30+
31+
import java.util.Collection;
32+
import java.util.concurrent.CountDownLatch;
33+
import java.util.concurrent.TimeUnit;
34+
35+
import static software.amazon.awssdk.benchmark.utils.BenchmarkConstant.CONCURRENT_CALLS;
36+
import static software.amazon.awssdk.benchmark.utils.BenchmarkUtils.awaitCountdownLatchUninterruptibly;
37+
import static software.amazon.awssdk.benchmark.utils.BenchmarkUtils.countDownUponCompletion;
38+
39+
/**
40+
* Using aws-crt-client to test against local mock https server.
41+
*/
42+
@State(Scope.Benchmark)
43+
@Warmup(iterations = 3, time = 15, timeUnit = TimeUnit.SECONDS)
44+
@Measurement(iterations = 5, time = 10, timeUnit = TimeUnit.SECONDS)
45+
@Fork(2) // To reduce difference between each run
46+
@BenchmarkMode(Mode.Throughput)
47+
public class AwsCrtClientNonTLSBenchmark implements SdkHttpClientBenchmark {
48+
49+
private MockServer mockServer;
50+
private SdkAsyncHttpClient sdkHttpClient;
51+
private ProtocolRestJsonAsyncClient client;
52+
53+
@Setup(Level.Trial)
54+
public void setup() throws Exception {
55+
mockServer = new MockServer();
56+
mockServer.start();
57+
58+
sdkHttpClient = AwsCrtAsyncHttpClient.builder()
59+
.verifyPeer(false)
60+
.build();
61+
62+
client = ProtocolRestJsonAsyncClient.builder()
63+
.endpointOverride(mockServer.getHttpUri())
64+
.httpClient(sdkHttpClient)
65+
.build();
66+
67+
// Making sure the request actually succeeds
68+
client.allTypes().join();
69+
}
70+
71+
@TearDown(Level.Trial)
72+
public void tearDown() throws Exception {
73+
mockServer.stop();
74+
client.close();
75+
sdkHttpClient.close();
76+
}
77+
78+
@Override
79+
@Benchmark
80+
@OperationsPerInvocation(CONCURRENT_CALLS)
81+
public void concurrentApiCall(Blackhole blackhole) {
82+
CountDownLatch countDownLatch = new CountDownLatch(CONCURRENT_CALLS);
83+
for (int i = 0; i < CONCURRENT_CALLS; i++) {
84+
countDownUponCompletion(blackhole, client.allTypes(), countDownLatch);
85+
}
86+
87+
awaitCountdownLatchUninterruptibly(countDownLatch, 10, TimeUnit.SECONDS);
88+
89+
}
90+
91+
@Override
92+
@Benchmark
93+
public void sequentialApiCall(Blackhole blackhole) {
94+
CountDownLatch countDownLatch = new CountDownLatch(1);
95+
countDownUponCompletion(blackhole, client.allTypes(), countDownLatch);
96+
awaitCountdownLatchUninterruptibly(countDownLatch, 1, TimeUnit.SECONDS);
97+
}
98+
99+
public static void main(String... args) throws Exception {
100+
Options opt = new OptionsBuilder()
101+
.include(AwsCrtClientNonTLSBenchmark.class.getSimpleName())
102+
.addProfiler(StackProfiler.class)
103+
.build();
104+
Collection<RunResult> run = new Runner(opt).run();
105+
}
106+
}

0 commit comments

Comments
 (0)