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.apicall.httpclient.async; 17 18 import java.net.URI; 19 import java.util.concurrent.TimeUnit; 20 import org.openjdk.jmh.annotations.BenchmarkMode; 21 import org.openjdk.jmh.annotations.Fork; 22 import org.openjdk.jmh.annotations.Measurement; 23 import org.openjdk.jmh.annotations.Mode; 24 import org.openjdk.jmh.annotations.Scope; 25 import org.openjdk.jmh.annotations.State; 26 import org.openjdk.jmh.annotations.Warmup; 27 import org.openjdk.jmh.profile.StackProfiler; 28 import org.openjdk.jmh.runner.Runner; 29 import org.openjdk.jmh.runner.options.Options; 30 import org.openjdk.jmh.runner.options.OptionsBuilder; 31 import software.amazon.awssdk.benchmark.utils.MockServer; 32 33 /** 34 * Using aws-crt-client to test against local mock https server. 35 */ 36 @State(Scope.Benchmark) 37 @Warmup(iterations = 3, time = 15, timeUnit = TimeUnit.SECONDS) 38 @Measurement(iterations = 5, time = 10, timeUnit = TimeUnit.SECONDS) 39 @Fork(2) // To reduce difference between each run 40 @BenchmarkMode(Mode.Throughput) 41 public class AwsCrtClientBenchmark extends BaseCrtBenchmark { 42 43 @Override getEndpointOverride(MockServer mock)44 protected URI getEndpointOverride(MockServer mock) { 45 return mock.getHttpsUri(); 46 } 47 main(String... args)48 public static void main(String... args) throws Exception { 49 Options opt = new OptionsBuilder() 50 .include(AwsCrtClientBenchmark.class.getSimpleName()) 51 .addProfiler(StackProfiler.class) 52 .build(); 53 new Runner(opt).run(); 54 } 55 } 56