[英]Program 5x slower as a .jar file than when ran in eclipse
Currently the speed to run a test function is about 5× slower when done with the jar file vs. doing it in Eclipse.目前,使用 jar 文件与在 Eclipse 中进行测试相比,运行测试 function 的速度大约慢5 倍。 How should I install the jar file so the speed is similar?我应该如何安装 jar 文件以使速度相似?
I am using maven.我正在使用 maven。 I am using outside dependencies.我正在使用外部依赖项。 I just need to know what is the best code for the build (in the pom file) to make it run as fast as possible, with no concern for copy rights.我只需要知道构建(在 pom 文件中)的最佳代码是什么,以使其尽可能快地运行,而不用担心版权。 The only thing I need is for the program to work on a machine without maven installed.我唯一需要的是让程序在没有安装 maven 的机器上运行。
Also, based on the last time I asked this, I will add more info that might be useful.另外,根据我上次提出的问题,我将添加更多可能有用的信息。 Java is up to date. Java 是最新的。 All is stored on the C drive.全部存储在 C 驱动器上。 There is no outputs that is slowing this down, and it is all text based.没有任何输出会减慢速度,而且都是基于文本的。 There is a lot of reading and writing on files going on that take time to do, but it took 16.6 seconds using Eclipse and 89.6 using the jar file.对文件进行大量读写需要时间,但使用 Eclipse 需要 16.6 秒,使用 jar 文件需要 89.6 秒。
Here is the pom file, including the dependencies:这是 pom 文件,包括依赖项:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kov</groupId>
<artifactId>etf-creator</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- to get html request for api -->
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
<!-- for a fast way to read in a file -->
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven -->
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>Driver</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Also, for someone reason it will not install when it was before.此外,由于某些原因,它不会像以前那样安装。 I get an error "Source option 5 is no longer supported. Use 7 or later."我收到错误消息“不再支持源选项 5。请使用 7 或更高版本。”
I am new to Eclipse and making executable jar files on Eclipse, so I appreciate the help.我是 Eclipse 的新手,并在 Eclipse 上制作可执行的 jar 文件,因此感谢您的帮助。
I figured it out.我想到了。 I needed more memory when running it.运行它时我需要更多 memory。 I ran it with this and works faster now:我用它运行它并且现在工作得更快:
java -Xms512m -Xmx1024m -jar mainProgram.jar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.