Add profile with performance tests
This commit is contained in:
parent
951a0f1b56
commit
7a13cb2ce5
2 changed files with 47 additions and 37 deletions
|
@ -35,6 +35,9 @@
|
||||||
<exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
|
<exec-maven-plugin.version>1.4.0</exec-maven-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>performance-test</id>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -63,5 +66,7 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -6,8 +6,16 @@ import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.ContentType;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.openjdk.jmh.annotations.*;
|
import org.openjdk.jmh.annotations.Benchmark;
|
||||||
import org.openjdk.jmh.infra.BenchmarkParams;
|
import org.openjdk.jmh.annotations.BenchmarkMode;
|
||||||
|
import org.openjdk.jmh.annotations.Measurement;
|
||||||
|
import org.openjdk.jmh.annotations.Mode;
|
||||||
|
import org.openjdk.jmh.annotations.OutputTimeUnit;
|
||||||
|
import org.openjdk.jmh.annotations.Scope;
|
||||||
|
import org.openjdk.jmh.annotations.Setup;
|
||||||
|
import org.openjdk.jmh.annotations.State;
|
||||||
|
import org.openjdk.jmh.annotations.TearDown;
|
||||||
|
import org.openjdk.jmh.annotations.Warmup;
|
||||||
import org.openjdk.jmh.infra.Blackhole;
|
import org.openjdk.jmh.infra.Blackhole;
|
||||||
import org.openjdk.jmh.infra.ThreadParams;
|
import org.openjdk.jmh.infra.ThreadParams;
|
||||||
import pl.touk.mockserver.api.request.AddMock;
|
import pl.touk.mockserver.api.request.AddMock;
|
||||||
|
@ -21,11 +29,10 @@ import java.util.concurrent.TimeUnit;
|
||||||
public class MockserverTest {
|
public class MockserverTest {
|
||||||
HttpMockServer httpMockServer;
|
HttpMockServer httpMockServer;
|
||||||
|
|
||||||
@Param({"9000", "8000"})
|
int initialPort = 9000;
|
||||||
int initialPort;
|
|
||||||
|
|
||||||
@Setup
|
@Setup
|
||||||
public void prepareMockServer(BenchmarkParams params) {
|
public void prepareMockServer() {
|
||||||
httpMockServer = new HttpMockServer(9999);
|
httpMockServer = new HttpMockServer(9999);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,11 +56,9 @@ public class MockserverTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
@Measurement(iterations = 10)
|
@Measurement(iterations = 20)
|
||||||
@Fork(value = 2)
|
|
||||||
@BenchmarkMode({Mode.AverageTime, Mode.Throughput, Mode.SampleTime})
|
@BenchmarkMode({Mode.AverageTime, Mode.Throughput, Mode.SampleTime})
|
||||||
@Warmup(iterations = 5)
|
@Warmup(iterations = 10)
|
||||||
@Threads(4)
|
|
||||||
public void shouldHandleManyRequestsSimultaneously(TestState testState, Blackhole bh) throws IOException {
|
public void shouldHandleManyRequestsSimultaneously(TestState testState, Blackhole bh) throws IOException {
|
||||||
int current = testState.current;
|
int current = testState.current;
|
||||||
int endpointNumber = current % 10;
|
int endpointNumber = current % 10;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue