Ami*_*far 13 java ide performance
我们有一个应用程序通过拆分数据并对其进行排序来导入大量文件.运行JUnit测试用例时,整个过程大约需要16分钟.
同样的测试,mvn clean test -Dtest=MyTest在34分钟内完成.
我们正在调用/bin/sort对文件进行排序.这种情况似乎需要更长的时间.我不明白有什么不同.
看看它运行的IntelliJ
/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
Run Code Online (Sandbox Code Playgroud)
我在OS X上.所有类都是使用Spring注入的.有哪些可能的建议是关于IntelliJ中这种性能提升背后的理论?测试是相同的.我无法分享所有代码,因为有这么多.但是我可以根据要求添加任何细节.
这是我的主要课程,以及我如何运行这两个课程.
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()));
}
Run Code Online (Sandbox Code Playgroud)
我决定删除JUnit并只使用main()方法.结果完全一样.IntelliJ又来了.这是疯狂的日志.
使用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]
Run Code Online (Sandbox Code Playgroud)
用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]
Run Code Online (Sandbox Code Playgroud)
sort命令是
sort -t' ' -f -k32,32f -k18,18f -k1,1n
Run Code Online (Sandbox Code Playgroud)
如您所见,在Intellij中排序需要1分钟,但在java -jar需要5分钟!
更新
我把所有东西都用完/Library/Java/JavaVirtualMachines/1.6.0_26-b03-383.jdk/Contents/Home/bin/java了,排序仍然需要5分钟以上.