Skip to content

Commit 12b37f4

Browse files
committed
Handled review comments
1 parent ad00477 commit 12b37f4

File tree

6 files changed

+61
-36
lines changed

6 files changed

+61
-36
lines changed

test/http-client-benchmarks/src/main/java/software/amazon/awssdk/benchmark/UnifiedBenchmarkRunner.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
package software.amazon.awssdk.benchmark;
1717

18+
import static software.amazon.awssdk.benchmark.apache5.utility.BenchmarkUtilities.isJava21OrHigher;
19+
1820
import java.time.Instant;
1921
import java.util.ArrayList;
2022
import java.util.Collection;
@@ -48,21 +50,7 @@ private static void printToConsole(String message) {
4850
// CHECKSTYLE:ON
4951
}
5052

51-
private static boolean isJava21OrHigher() {
5253

53-
String version = JavaSystemSetting.JAVA_VERSION.getStringValueOrThrow();
54-
if (version.startsWith("1.")) {
55-
version = version.substring(2);
56-
}
57-
int dotPos = version.indexOf('.');
58-
int majorVersion;
59-
if (dotPos != -1) {
60-
majorVersion = Integer.parseInt(version.substring(0, dotPos));
61-
} else {
62-
majorVersion = Integer.parseInt(version);
63-
}
64-
return majorVersion >= 21;
65-
}
6654

6755
public static void main(String[] args) throws Exception {
6856
// Update logging calls to use Supplier<String> pattern

test/http-client-benchmarks/src/main/java/software/amazon/awssdk/benchmark/apache4/Apache4Benchmark.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ public class Apache4Benchmark implements CoreBenchmark {
5656
@Param({"50"})
5757
private int maxConnections;
5858

59-
@Param({"20"})
59+
@Param({"5"})
60+
private int testDataInMB;
61+
62+
@Param({"10"})
6063
private int threadCount;
6164

6265
private S3Client s3Client;
@@ -82,7 +85,7 @@ public void setup() {
8285
.build();
8386

8487
// Initialize benchmark implementation
85-
benchmark = new S3BenchmarkImpl(s3Client);
88+
benchmark = new S3BenchmarkImpl(s3Client, new byte[testDataInMB * 1024 * 1024]);
8689
benchmark.setup();
8790

8891
// Platform thread pool for multi-threaded tests

test/http-client-benchmarks/src/main/java/software/amazon/awssdk/benchmark/apache5/Apache5Benchmark.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public class Apache5Benchmark implements CoreBenchmark {
5757
@Param({"50"})
5858
private int maxConnections;
5959

60+
@Param({"5"})
61+
private int testDataInMB;
62+
6063
@Param({"10"})
6164
private int threadCount;
6265

@@ -87,7 +90,7 @@ public void setup() {
8790
.build();
8891

8992
// Initialize benchmark implementation
90-
benchmark = new S3BenchmarkImpl(s3Client);
93+
benchmark = new S3BenchmarkImpl(s3Client, new byte[this.testDataInMB * 1024 * 1024]);
9194
benchmark.setup();
9295

9396
// Always use platform threads

test/http-client-benchmarks/src/main/java/software/amazon/awssdk/benchmark/apache5/Apache5VirtualBenchmark.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
package software.amazon.awssdk.benchmark.apache5;
1717

18+
import static software.amazon.awssdk.benchmark.apache5.utility.BenchmarkUtilities.isJava21OrHigher;
19+
1820
import java.lang.reflect.InvocationTargetException;
1921
import java.lang.reflect.Method;
2022
import java.time.Duration;
@@ -64,13 +66,18 @@ public class Apache5VirtualBenchmark implements CoreBenchmark {
6466
@Param({"50"})
6567
private int maxConnections;
6668

69+
@Param({"5"})
70+
private int testDataInMB;
71+
6772
@Param({"10"})
6873
private int threadCount;
6974

7075
private S3Client s3Client;
7176
private S3BenchmarkImpl benchmark;
7277
private ExecutorService executorService;
7378

79+
80+
7481
@Setup(Level.Trial)
7582
public void setup() {
7683
// Verify Java version
@@ -102,7 +109,7 @@ public void setup() {
102109
.build();
103110

104111
// Initialize benchmark implementation
105-
benchmark = new S3BenchmarkImpl(s3Client);
112+
benchmark = new S3BenchmarkImpl(s3Client, new byte[this.testDataInMB * 1024 * 1024]);
106113
benchmark.setup();
107114

108115
// Create virtual thread executor
@@ -114,21 +121,6 @@ public void setup() {
114121
logger.info(() -> "Apache5 virtual threads benchmark setup complete");
115122
}
116123

117-
private boolean isJava21OrHigher() {
118-
String version = JavaSystemSetting.JAVA_VERSION.getStringValueOrThrow();
119-
if (version.startsWith("1.")) {
120-
version = version.substring(2);
121-
}
122-
int dotPos = version.indexOf('.');
123-
int majorVersion;
124-
if (dotPos != -1) {
125-
majorVersion = Integer.parseInt(version.substring(0, dotPos));
126-
} else {
127-
majorVersion = Integer.parseInt(version);
128-
}
129-
return majorVersion >= 21;
130-
}
131-
132124
private ExecutorService createVirtualThreadExecutor() {
133125
try {
134126
// Use reflection to call Executors.newVirtualThreadPerTaskExecutor()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 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.apache5.utility;
17+
18+
import software.amazon.awssdk.utils.JavaSystemSetting;
19+
20+
public final class BenchmarkUtilities {
21+
22+
private BenchmarkUtilities() {
23+
}
24+
25+
public static boolean isJava21OrHigher() {
26+
String version = JavaSystemSetting.JAVA_VERSION.getStringValueOrThrow();
27+
if (version.startsWith("1.")) {
28+
version = version.substring(2);
29+
}
30+
int dotPos = version.indexOf('.');
31+
int majorVersion;
32+
if (dotPos != -1) {
33+
majorVersion = Integer.parseInt(version.substring(0, dotPos));
34+
} else {
35+
majorVersion = Integer.parseInt(version);
36+
}
37+
return majorVersion >= 21;
38+
}
39+
}
40+

test/http-client-benchmarks/src/main/java/software/amazon/awssdk/benchmark/core/S3BenchmarkImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ public class S3BenchmarkImpl {
4949
private final String bucketName;
5050
private final byte[] testData;
5151

52-
public S3BenchmarkImpl(S3Client s3Client) {
52+
public S3BenchmarkImpl(S3Client s3Client, byte[] testData) {
5353
this.s3Client = s3Client;
5454
this.bucketName = "benchmark-bucket-" + UUID.randomUUID().toString().substring(0, 8);
55-
// 5MB test data
56-
this.testData = new byte[5 * 1024 * 1024];
55+
this.testData = testData;
5756
ThreadLocalRandom.current().nextBytes(testData);
5857
}
5958

0 commit comments

Comments
 (0)