为什么项目“运行” NetBeans内部终端比windows命令提示符更快? [英] Why does a project "run" faster in NetBeans internal terminal than in windows command prompt?

查看:189
本文介绍了为什么项目“运行” NetBeans内部终端比windows命令提示符更快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这个论坛上是新的,所以请原谅我,如果我没有第一次问这个问题。
我认为没有必要在这里提供代码,因为我认为它与代码无关,问题可能更普遍。



我在Windows XP中使用MinGW(g ++)在NetBeans 7.1.2中编写和构建了一个C ++项目。两者兼容,Debug版本和Release版本都能正常工作,并提供所需的计算输出。但是,如果我在NetBeans内部终端中运行项目(任一项目),我可以测量115到130微秒之间的计算时间。如果我在Windows命令提示符下执行exe文件,我测量的计算时间在500到3000微秒之间。 (在2.2 GHz Intel Core 2 Duo上,带有2 GB RAM,我通过读取复位后的CPU时钟周期数除以cpu频率来测量时间。)

我在另一台计算机上尝试过相同(包括建设项目),还有2.2 GHz和16 GB的Ram和Windows7。程序运行速度有点快,但是模式是一样的。当我从NetBeans运行项目,但在外部终端(也是Windows终端)运行时,情况也是如此。而且它适用于这两个版本,调试和发行版本。



其中一个计算(不是最重要的时间)是快速傅里叶变换,取决于fftw ( http://www.fftw.org/ )libfftw3-3.dll库。在NetBeans中,它的位置是已知的,在Windows命令提示符下,dll必须与可执行文件在同一目录中。为什么在NetBeans的内部终端窗口中,程序运行速度比Windows命令提示符窗口快得多?



它可以与加载时的库的动态链接有关吗?

但是,在Windows中实际需要更长时间的计算步骤命令提示符比NetBeans的终端不依赖于dll中的函数(两个comlex号的乘法)。



最耗时的并且程序中的关键计算是两个复数数组的类型 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 code> y 是两个复数数组,其中 [i] [0] 保存实部, [i] [1] 保留虚部。 result 是相同类型的预分配数组。

当程序在NetBeans内部执行时,此循环大小为5微秒,长度为513的数组终端,而是在Windows命令提示符下运行程序时100微秒。我在sehe的答案中找不到所有真正有用的建议的解释。



请让我知道,如果你认为它与实际代码有关,那么我会提供一些。



我已经寻找类似的问题,但找不到任何内容。任何提示或指向我可能会错过的其他问题和答案都是赞赏。
干杯。

解决方案

根据我的评论:


你做很多控制台IO? Microsoft控制台窗口臭名昭着的


还要看看ENVIRONMENT变量,特别是:




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. Both, the Debug version and the Release version work fine and deliver the desired output of the computations. However, if I "run" the project (either project) in NetBeans' internal terminal, I can measure computation times of between 115 and 130 microseconds. If I execute the exe file in a Windows command prompt, I measure computation times of between 500 and 3000 microseconds. (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.)
I tried the same on another computer (incl. building the project), also 2.2 GHz and 16 GB Ram and 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). 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. Within NetBeans its location is known, in the windows command prompt, the dll has to be in the same directory as the executable.

Why is it, that a program runs so much faster in NetBeans' internal terminal window than in a windows command prompt window?

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

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

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. result is a preallocated array of the same type.
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. I could not find an explanation in all the really helpful advice in the answer by 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? Microsoft console windows are notoriously slow

Also look at the ENVIRONMENT variables, notably:

这篇关于为什么项目“运行” NetBeans内部终端比windows命令提示符更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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