.jar文件的编程速度比在Eclipse中运行时慢5倍 [英] Program 5x slower as a .jar file than when ran in eclipse

查看:165
本文介绍了.jar文件的编程速度比在Eclipse中运行时慢5倍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,与jar文件相比,与Eclipse中相比,运行测试功能的速度要慢 5倍。我应该如何安装jar文件,使速度相近?

Currently the speed to run a test function is about slower when done with the jar file vs. doing it in Eclipse. How should I install the jar file so the speed is similar?

我正在使用Maven。我正在使用外部依赖项。我只需要知道什么是构建的最佳代码(在pom文件中),以使其尽可能快地运行,而不用担心复制权限。我唯一需要的是使程序在没有安装Maven的机器上运行。

I am using 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. The only thing I need is for the program to work on a machine without maven installed.

此外,根据我上次询问的时间,我将添加更多信息可能会有用。 Java是最新的。全部存储在C驱动器中。没有输出会减慢此速度,它全部基于文本。对文件进行大量的读取和写入需要时间,但是使用Eclipse花费了16.6秒,使用jar文件花费了89.6。

Also, based on the last time I asked this, I will add more info that might be useful. Java is up to date. All is stored on the C drive. 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.

这里是pom文件,包括依赖项:

Here is the pom file, including the dependencies:

<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>

此外,由于某些原因,以前无法安装。我收到错误消息不再支持源选项5。请使用7或更高版本。

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."

我是Eclipse的新手,正在Eclipse上制作可执行jar文件,因此,我对此表示赞赏。

I am new to Eclipse and making executable jar files on Eclipse, so I appreciate the help.

推荐答案

我知道了。运行它时需要更多内存。
我用它运行它并且现在可以更快地工作:

I figured it out. I needed more memory when running it. I ran it with this and works faster now:

java -Xms512m -Xmx1024m -jar mainProgram.jar

这篇关于.jar文件的编程速度比在Eclipse中运行时慢5倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆