为什么代码在调试模式下工作,但在 İntellij 上不能在发布模式下工作
Why the code works on debuggin mode but not works on release mode on İntellij
我正在做一个关于算法效率的实验,所以当我 运行 下面的代码
for (int i=0; i<experiment.length; i++) {
System.out.println("experiment number : "+i);
for (int j = 0; j < 10; j++) {
ArrayList<Integer> exp_array = new ArrayList<>();
if(i==9){
exp_array.addAll(array.subList(0, experiment[i]));
}else {
exp_array.addAll(array.subList(0, experiment[i]+1));
}
long startTime = System.currentTimeMillis();
insertionSort.sort(exp_array);
long elapsedTime = System.currentTimeMillis() - startTime;
resultsInsertion1.add(elapsedTime);
if(j==9){
sortedArrays.add(exp_array);
}
}
averageResultsInsertion1.add(avarage.findAverage(resultsInsertion1));
resultsInsertion1.clear();
}
System.out.println(averageResultsInsertion1);
// insertion2
ArrayList<Long> resultsInsertion2 = new ArrayList<>();
ArrayList<Long> averageResultsInsertion2 = new ArrayList<>();
for (int i=0; i<experiment.length; i++) {
System.out.println("experiment number : "+i);
for (int j = 0; j < 10; j++) {
long startTime = System.currentTimeMillis();
insertionSort.sort(sortedArrays.get(i));
long elapsedTime = System.currentTimeMillis() - startTime;
resultsInsertion2.add(elapsedTime);
}
averageResultsInsertion2.add(avarage.findAverage(resultsInsertion2));
resultsInsertion2.clear();
}
System.out.println("insertion 2 : "+averageResultsInsertion2);
averaResultsInsertion2 为我提供了充满零的数组,但是当我 运行 代码在调试模式下它工作时,我该如何解决这个问题?
PC:MacBook Air 2017
IDE:Intellij 2022
ResultsInsertion2 填充了以毫秒为单位的 elapsed 时间,因此如果您的排序在一毫秒内执行,您将得到 ..zeros
ps : 请下次格式化您的代码
我正在做一个关于算法效率的实验,所以当我 运行 下面的代码
for (int i=0; i<experiment.length; i++) {
System.out.println("experiment number : "+i);
for (int j = 0; j < 10; j++) {
ArrayList<Integer> exp_array = new ArrayList<>();
if(i==9){
exp_array.addAll(array.subList(0, experiment[i]));
}else {
exp_array.addAll(array.subList(0, experiment[i]+1));
}
long startTime = System.currentTimeMillis();
insertionSort.sort(exp_array);
long elapsedTime = System.currentTimeMillis() - startTime;
resultsInsertion1.add(elapsedTime);
if(j==9){
sortedArrays.add(exp_array);
}
}
averageResultsInsertion1.add(avarage.findAverage(resultsInsertion1));
resultsInsertion1.clear();
}
System.out.println(averageResultsInsertion1);
// insertion2
ArrayList<Long> resultsInsertion2 = new ArrayList<>();
ArrayList<Long> averageResultsInsertion2 = new ArrayList<>();
for (int i=0; i<experiment.length; i++) {
System.out.println("experiment number : "+i);
for (int j = 0; j < 10; j++) {
long startTime = System.currentTimeMillis();
insertionSort.sort(sortedArrays.get(i));
long elapsedTime = System.currentTimeMillis() - startTime;
resultsInsertion2.add(elapsedTime);
}
averageResultsInsertion2.add(avarage.findAverage(resultsInsertion2));
resultsInsertion2.clear();
}
System.out.println("insertion 2 : "+averageResultsInsertion2);
averaResultsInsertion2 为我提供了充满零的数组,但是当我 运行 代码在调试模式下它工作时,我该如何解决这个问题?
PC:MacBook Air 2017 IDE:Intellij 2022
ResultsInsertion2 填充了以毫秒为单位的 elapsed 时间,因此如果您的排序在一毫秒内执行,您将得到 ..zeros
ps : 请下次格式化您的代码