Java – why does my application run faster than the command line in IntelliJ?

We have an application that imports a large number of files by splitting data and sorting it When running JUnit test cases, the whole process takes about 16 minutes

The same test is completed with MVN cleaning test - DTest = mytest runs in 34 minutes

We are calling / bin / sort to sort the files This seems to take longer I don't understand the difference

Look at IntelliJ, it runs

/Library/Java/JavaVirtualMachines/1.6.0_26-b03-383.jdk/Contents/Home/bin/java -Didea.launcher.port=7532 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA 10.app/bin -Dfile.encoding=UTF-8 -classpath %classhpath% com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 xxx.IntTestImportProcess,testImportProcess

I'm on OS X All classes use spring injection What are some possible suggestions for the theory behind IntelliJ's performance benefits? The test is the same I can't share all the code because there are so many But I can add any details if necessary

This is my main course and how I run it

public static void main(String... args) throws IOException {
        if(args.length != 2) {
            System.out.println("Usage: \n  java -jar client.jar spring.xml data_file");
            System.exit(1);
        }
        ApplicationContext applicationContext = new FileSystemXmlApplicationContext(args[0]);
        PeriodFormatter formatter = new PeriodFormatterBuilder()
                .appendMinutes()
                .appendSuffix("minute","minutes")
                .appendSeparator(" and ")
                .appendSeconds()
                .appendSuffix("second","seconds")
                .toFormatter();
        URI output = (URI) applicationContext.getBean("workingDirectory");
        File dir = new File(output);
        if(dir.exists()) {
            Files.deleteDirectoryContents(dir.getCanonicalFile());
        }
        else {
            dir.mkdirs();
        }
        ImportProcess importProcess = applicationContext.getBean(ImportProcess.class);
        long start = System.currentTimeMillis();
        File file = new File(args[1]);
        importProcess.beginImport(file);
        Period period = new Period(System.currentTimeMillis() - start); // in milliseconds
        System.out.println(formatter.print(period.toPeriod()));
    }

I decided to delete JUnit by using only one main () method The result is exactly the same IntelliJ again This is a crazy log

Using IntelliJ

DEBUG [ main] 2011-08-18 13:05:16,259 [er.DelimitedTextUnixDataSorter] Sorting file [/Users/amirraminfar/Desktop/import-process/usage]
DEBUG [ main] 2011-08-18 13:06:09,546 [er.DelimitedTextUnixDataSorter] Sorting file [/Users/amirraminfar/Desktop/import-process/customer]

Using java jar

DEBUG [ main] 2011-08-18 12:10:16,726 [er.DelimitedTextUnixDataSorter] Sorting file [/Users/amirraminfar/Desktop/import-process/usage]
DEBUG [ main] 2011-08-18 12:15:55,893 [er.DelimitedTextUnixDataSorter] Sorting file [/Users/amirraminfar/Desktop/import-process/customer]

The sort command is

sort -t'    ' -f -k32,32f -k18,18f -k1,1n

As mentioned above, sorting in IntelliJ takes 1 minute, but it takes 5 minutes in Java - jar!

to update

I use / library / Java / javavirtualmachines / 1.6 0_ 26-b03-383. JDK / contents / home / bin / Java runs all the contents, and sorting still takes more than 5 minutes

Solution

Thank you for your help It turns out that IntelliJ started sorting with lang = C By default, Mac OS X terminals are sorted in utf8, which explains the performance loss I hope this answer can help others

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>