简体   繁体   English

为什么项目在NetBeans内部终端中比在Windows命令提示符下“运行”更快?

[英]Why does a project “run” faster in NetBeans internal terminal than in windows command prompt?

I am new in this forum, so excuse me if I am not asking the question right the first time. 我是这个论坛的新人,请原谅我,如果我第一次没有正确地提出这个问题。 I think it is not necessary to provide code here since I think it has nothing to do with the code and the question might be more general. 我认为没有必要在这里提供代码,因为我认为它与代码无关,问题可能更为一般。

I have written and built a C++ project in NetBeans 7.1.2 using MinGW (g++) in Windows XP. 我在Windows XP中使用MinGW(g ++)在NetBeans 7.1.2中编写并构建了一个C ++项目。 Both, the Debug version and the Release version work fine and deliver the desired output of the computations. Debug版本和Release版本都可以正常工作,并提供所需的计算输出。 However, if I "run" the project (either project) in NetBeans' internal terminal, I can measure computation times of between 115 and 130 microseconds. 但是,如果我在NetBeans的内部终端中“运行”项目(任一项目),我可以测量115到130微秒之间的计算时间。 If I execute the exe file in a Windows command prompt, I measure computation times of between 500 and 3000 microseconds. 如果我在Windows命令提示符下执行exe文件,我测量的计算时间在500到3000微秒之间。 (On a 2.2 GHz Intel Core 2 Duo with 2 GB Ram. I measure the time by reading the number of cpu clock ticks since reset and dividing by the cpu frequency.) (在带有2 GB Ram的2.2 GHz Intel Core 2 Duo上。我通过读取自复位后的cpu时钟周期数除以cpu频率来测量时间。)
I tried the same on another computer (incl. building the project), also 2.2 GHz and 16 GB Ram and Windows7. 我在另一台计算机(包括构建项目),2.2 GHz和16 GB Ram和Windows7上尝试了相同的操作。 The program runs a bit faster, but the pattern is the same. 该程序运行得更快,但模式是相同的。 The same is true, when I run the project from NetBeans but in an external terminal (also windows terminal). 当我从NetBeans运行项目但在外部终端(也是Windows终端)时也是如此。 And it applies to both versions, the debug and the release version. 它适用于两个版本,调试和发布版本。

One of the computations (not the most time critical) is a Fast Fourier Transform and depends on the fftw ( http://www.fftw.org/ ) "libfftw3-3.dll" library. 其中一个计算(不是最关键的时间)是快速傅立叶变换,它依赖于fftw( http://www.fftw.org/ )"libfftw3-3.dll“库。 Within NetBeans its location is known, in the windows command prompt, the dll has to be in the same directory as the executable. 在NetBeans中,其位置是已知的,在Windows命令提示符下,dll必须与可执行文件位于同一目录中。

Why is it, that a program runs so much faster in NetBeans' internal terminal window than in a windows command prompt window? 为什么一个程序在NetBeans的内部终端窗口中比在Windows命令提示符窗口中运行得快得多?

Could it have something to do with the dynamic linking of the library at load time? 它可能与加载时库的动态链接有关吗?
However, the computation step that actually takes longer in windows command prompt than in NetBeans' terminal does not depend on the functions in the dll (the multiplication of two comlex numbers). 但是,在Windows命令提示符中实际需要比在NetBeans终端中实际需要更长时间的计算步骤不依赖于dll中的函数(两个复合数字的乘法)。

The most time consuming and crucial computation in the program is the multiplication of two arrays of complex number of type fftw_complex which is double[2] : 程序中最耗时关键的计算是两个复数fftw_complex数组的乘法,它是double[2]

for(int i = 0; i < n; ++i) {  

    double k1 = x[i][0] * (y[i][0] - y[i][1]);  
    double k2 = (y[i][1] * -1) * (x[i][0] + x[i][1]);  
    double k3 = y[i][0] * (x[i][1] - x[i][0]);  


    result[i][0] = k1 - k2;  
    result[i][1] = k1 + k3;  
}  

x and y are two arrays of complex numbers where [i][0] holds the real part and [i][1] holds the imaginary part. xy是两个复数数组,其中[i][0]保持实部, [i][1]保持虚部。 result is a preallocated array of the same type. result是一个相同类型的预分配数组。
This loop takes about 5 microseconds for arrays of length 513 when the program is executed in NetBeans' internal terminal, but rather 100 microseconds when I run the program in a Windows command prompt. 当程序在NetBeans的内部终端中执行时,对于长度为513的数组,此循环大约需要5微秒,而在Windows命令提示符下运行程序时则为100微秒。 I could not find an explanation in all the really helpful advice in the answer by sehe. 在sehe的答案中,我无法找到所有真正有用的建议的解释。

Please let me know, if you think it has something to do with the actual code, then I would provide some. 请让我知道,如果您认为它与实际代码有关,那么我会提供一些。

I have looked for similar questions, but could not find any. 我找了类似的问题,但找不到任何问题。 Any hints or points to other questions and answers that I might have missed are appreciated. 任何我可能错过的其他问题和答案的提示或要点都表示赞赏。 Cheers. 干杯。

As per my comment: 根据我的评论:

Do you do much console IO? 你做了很多控制台IO吗? Microsoft console windows are notoriously slow 微软的控制台窗口非常慢

Also look at the ENVIRONMENT variables, notably: 另请参阅ENVIRONMENT变量,特别是:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么Windows命令提示符说“更多? “当我运行一个带有d ^参数的程序时? - Why does the Windows command prompt say “More? ” when I run a program with an argument of d^? 为什么从Windows启动但不在命令提示符下运行程序? - Why would a program run when launch from windows but not the command prompt? 在命令提示符下运行 C++ - Windows - Run C++ in command prompt - Windows Linux上的程序速度比Windows快 - 为什么? - Same program faster on Linux than Windows — why? Wine上的可执行文件运行速度比Windows快 - 为什么? - Executable runs faster on Wine than Windows — why? 为什么 std::fstream 在 Windows 上比 WriteFile 快 - Why is std::fstream faster than WriteFile on Windows NetBeans在外部终端中运行 - NetBeans Run in external terminal 为什么这个简单的lambda在std :: thread中始终比在gcc 4.9.2的main函数中运行更快? - Why does this simple lambda consistently run faster inside an std::thread than inside the main function with gcc 4.9.2? 为什么用于测试 Collat​​z 猜想的 C++ 代码比手写程序集运行得更快? - Why does C++ code for testing the Collatz conjecture run faster than hand-written assembly? 为什么我的程序在 CPU 设备上的运行速度比在 GPU 设备上快得多? - Why does my program run significantly faster on my CPU device than on my GPU device?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM