应用程序在日食中运行速度更快 [英] Application runs faster in eclipse
问题描述
问题是当我导出可运行的jar时,我说java -jar myapp。 jar,每个对数据库的请求都需要大约9秒。
我不明白为什么当我从eclipse运行应用程序时更快...
事实上,每当我向数据库发出请求时,我都在创建一个实体经理:
Persistence.createEntityManagerFactory(mysqldb);
为了优化实体管理器的创建,我使用了一个这样的单身实体工厂: p>
private static EntityManagerFactory em = Persistence
.createEntityManagerFactory(mysqldb);
public static EntityManagerFactory getEmf()
{
return em;
}
这有助于提高eclipse之外的应用程序的性能,但没有当我在eclipse中运行它时,性能的变化。
我不太确定当从eclipse启动应用程序时它的工作原理是什么,但是这个解决方案解决了我现在的问题。
I have a runnable java SE application in eclipse. I bootstrap JPA to work in a normal java 6 SE environment. Each request to the different tables in the database doesn't take more than 100ms.
The problem is that when I export the runnable jar and I say java -jar myapp.jar, each of the request to the database take around 9 seconds.
I don't Understand why the application is faster when I run it from eclipse
In fact, each time I was doing a request to the database, I was creating an entity manager:
Persistence.createEntityManagerFactory( "mysqldb" );
In order to optimize the creation of the entity manager I use a singleton entity factory like that:
private static EntityManagerFactory em = Persistence
.createEntityManagerFactory( "mysqldb" );
public static EntityManagerFactory getEmf()
{
return em;
}
this worked to improve the performance of the application outside eclipse, but there is no change in the performance when i run it inside eclipse.
I am not really sure of what is the reason it worked better when the application was launched from eclipse, but this solution solved my problem for the moment.
这篇关于应用程序在日食中运行速度更快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!