forked from dsyer/spring-boot-startup-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use @param instead of a naming convention on the state class
- Loading branch information
Showing
4 changed files
with
156 additions
and
208 deletions.
There are no files selected for viewing
200 changes: 0 additions & 200 deletions
200
static/src/main/java/com/example/bench/DemoBenchmark.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
static/src/main/java/com/example/bench/SampleBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright 2016-2017 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.example.bench; | ||
|
||
import com.example.demo.DemoApplication; | ||
|
||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Level; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.Param; | ||
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; | ||
|
||
@Measurement(iterations = 5) | ||
@Warmup(iterations = 1) | ||
@Fork(value = 2, warmups = 0) | ||
@BenchmarkMode(Mode.AverageTime) | ||
public class SampleBenchmark { | ||
|
||
@Benchmark | ||
public void main(ApplicationState state) throws Exception { | ||
state.setMainClass(DemoApplication.class.getName()); | ||
state.run(); | ||
} | ||
|
||
@State(Scope.Benchmark) | ||
public static class ApplicationState extends ProcessLauncherState { | ||
|
||
public static enum Sample { | ||
empt, demo, actr, jdbc, actj, jpae, conf, erka, busr, zuul, erkb, slth; | ||
} | ||
|
||
@Param | ||
private Sample sample = Sample.demo; | ||
|
||
public ApplicationState() { | ||
super("target", "--server.port=0"); | ||
} | ||
|
||
@TearDown(Level.Iteration) | ||
public void stop() throws Exception { | ||
super.after(); | ||
} | ||
|
||
@Setup(Level.Trial) | ||
public void start() throws Exception { | ||
if (sample!=Sample.demo) { | ||
setProfiles(sample.toString()); | ||
} | ||
super.before(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright 2016-2017 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.example.bench; | ||
|
||
import com.example.func.FuncApplication; | ||
import com.example.lite.LiteApplication; | ||
import com.example.slim.SlimApplication; | ||
import com.example.thin.ThinApplication; | ||
|
||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Level; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
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; | ||
|
||
@Measurement(iterations = 5) | ||
@Warmup(iterations = 1) | ||
@Fork(value = 2, warmups = 0) | ||
@BenchmarkMode(Mode.AverageTime) | ||
public class SlimBenchmark { | ||
|
||
@Benchmark | ||
public void slim(ApplicationState state) throws Exception { | ||
state.setMainClass(SlimApplication.class.getName()); | ||
state.run(); | ||
} | ||
|
||
@Benchmark | ||
public void thin(ApplicationState state) throws Exception { | ||
state.setMainClass(ThinApplication.class.getName()); | ||
state.run(); | ||
} | ||
|
||
@Benchmark | ||
public void lite(ApplicationState state) throws Exception { | ||
state.setMainClass(LiteApplication.class.getName()); | ||
state.run(); | ||
} | ||
|
||
@Benchmark | ||
public void func(ApplicationState state) throws Exception { | ||
state.setMainClass(FuncApplication.class.getName()); | ||
state.run(); | ||
} | ||
|
||
@State(Scope.Benchmark) | ||
public static class ApplicationState extends ProcessLauncherState { | ||
|
||
public ApplicationState() { | ||
super("target", "--server.port=0"); | ||
} | ||
|
||
@TearDown(Level.Iteration) | ||
public void stop() throws Exception { | ||
super.after(); | ||
} | ||
|
||
@Setup(Level.Trial) | ||
public void start() throws Exception { | ||
super.before(); | ||
} | ||
} | ||
|
||
} |