I have a following piece of code
@SpringBootApplication
public class ServerApplication {
public static void main(String[] args) {
SpringApplication.run(ServerApplication.class, args);
OptimalTerminationTimeFinder.findOptimalTerminationTime(
8,
10,
50,
Duration.ofSeconds(1),
Duration.ofMillis(250));
}
where OptimalTerminationFinder
solves hundreds of problems and tries to find the best termination time for a given problem size.
The problem is that when I comment the annotation @SpringBootApplication
, the score evaluation speed increases from 40k to 80k and vice versa.
Why is Spring slowing down the solver so much? I read the user guide for Spring and the only difference is that they use a SolverManager
but that's not the problem, is it? I just use the Solver
class.
I cannot afford such a drastic speed decrease with Spring - the time difference is crucial at the production.
I reproduced the performance difference with java-spring-boot quickstart.
I believe the slower calculation speed is somehow caused by running the application using the spring-boot-maven-plugin
(I assume the plugin is also used by your IDE if you try to run a @SpringBootApplication
annotated class).
If you first build an executable JAR of your project and then run the JAR either in your IDE or from the terminal using java -jar ...
, you'll see the full speed score calculation.
I don't have an explanation of why the Spring Boot Maven Plugin prevents full performance but the production build of your application won't suffer from that.