速度vc ++与c ++构建器 [英] speed vc++ vs. c++builder
问题描述
您好,
我是一个视觉c ++和borland c ++构建器新手。
i有一个简单的mandelbrot算法,并用两者编译它/>
vc ++(mfc)和cbuilder(vcl)(除了绘图部分之外的相同代码)。
vc ++版本是两次!在发布模式下快速。在调试模式下它的价格和cbuilder一样快。似乎我不能让cbuilder编译一个真正的
发布版本。当我检查项目选项:编译器:发布时它
甚至比调试慢!我使用
高级编译器选项玩了一下而没有任何结果。我也放弃了
绘图部分,假设它会以某种方式导致减速。 cbuilder
版本并不比delphi 7上的相同代码快(可能是相同的
问题)。我能做什么?我不相信cbuilder(和delphi)比vc ++慢得多。我认为这只是找到
正确的编译器选项的问题。
谢谢。
代码:
for(y = 0; y< ymax; y ++)
{
for(x = 0; x< xmax ; x ++)
{
cox = x * xscale + leftside;
coy = y * yscale + top;
zx = 0;
zy = 0;
colorcounter = 0;
betrq = 0;
zaehler = 0;
while(colorcounter< maxiter&& betrq< bailout)
{
tempx = zx * zx-zy * zy + cox;
zy = 2 * zx * zy + coy;
zx = tempx;
colorcounter = colorcounter + 1;
betrq = zx * zx + zy * zy;
}
if(betrq< bailout)/ *在x处绘制黑色像素,y * /;
else / *在x,y * /)处绘制白色像素;
}
}
系统:
vc ++:visual studio 6.0
c ++ builder 6 enterprise
windows xp home sp1
intel pentium m(centrino)1400mhz
" PDQBach" < PO ***** @ freenet.de>写了...我是一个视觉c ++和borland c ++ builder newbie。
我已经找到了一个简单的mandelbrot算法,并使用
vc ++(mfc)和cbuilder进行编译(vcl)(除了绘图部分之外的相同代码)。
vc ++版本是两次!在发布模式下快速。在调试模式下它的速度和cbuilder一样快。似乎我不能让cbuilder编译一个真正的
发布版本。当我检查项目选项:编译器:发布时它甚至比调试慢!我使用
高级编译器选项玩了一下而没有任何结果。我也放弃了
绘图部分,假设它会以某种方式导致减速。 cbuilder
版本并不比delphi 7上的相同代码快(可能是相同的问题)。我能做什么?我不相信cbuilder(和delphi)比vc ++慢得多。我认为它只是找到正确的编译器选项的问题。
对。要解决它,你需要发布到C ++ Builder新闻组
而不是C ++语言。你没有_language_问题。
正如你所确定的那样,你的问题在于找到合适的
编译器选项。试试borland.public.cppbuilder。*层次结构。
Victor
po ***** @ freenet.de (PDQBach)在留言新闻中写道:< 6f ****************** ********@posting.google。 com> ...你好,
我是一个视觉c ++和borland c ++ builder newbie。
我已经找到了一个简单的mandelbrot算法并用它编译
vc ++(mfc)和cbuilder(vcl)(除了绘图部分之外的相同代码)。
vc ++版本是两次!在发布模式下快速。在调试模式下它的速度和cbuilder一样快。
这是偏离主题的,但这是相当典型的 - 作为一般规则,
Borland编译器优化相对较差。通过一些工作,你可以在某种程度上提高它的价值,但是它有可能会保持一定的价格,但是b / b
后来,
杰瑞。
-
宇宙是自己想象的虚构。
对不起蜂场。谢谢你的回答。
<但是很有可能它会保持有点慢。
我的呼叫速度不会快两倍。我更喜欢使用bcb来轻松使用
,但这种差异是不可接受的。我得到的结果与
相同:
#include" stdafx.h"
#include< time .h>
#include< conio.h>
#include< iostream>
using namespace std;
void main(){
clock_t beg;
double j;
beg = clock();
for(double i = 0; i< 200000000; ++ i)j = i * 1000000;
int dif = clock() - beg;
cout<< dif<< endl;
getch();
我认为没有什么可以优化的?怎么不能bcb优化器搞砸了?b $ b这么简单的东西? (对不起继续留言)
Hello,
im a visual c++ und borland c++builder newbie.
i have witten a simple mandelbrot algorithm and compiled it with both
vc++ (mfc) and cbuilder (vcl) (same code besides the drawing part).
the vc++ version is twice! as fast in release mode. in debug mode its
as fast as cbuilder. it seems i cant get cbuilder to compile a real
release version. when i check "Project options:compiler:release" it
even gets slower than debug! i have played around a bit with the
advanced compiler options without any result. i also dropped the
drawing part, supposing that it causes slowdown somehow. the cbuilder
version is not faster than the same code on delphi 7 (maybe the same
problem). what can i do? i cant believe cbuilder (and delphi) to be
that much slower than vc++. i think its just a problem of finding the
right compiler options.
thank you.
code:
for (y=0;y<ymax;y++)
{
for (x=0;x<xmax;x++)
{
cox=x*xscale+leftside;
coy=y*yscale+top;
zx=0;
zy=0;
colorcounter=0;
betrq=0;
zaehler=0;
while (colorcounter<maxiter && betrq<bailout)
{
tempx=zx*zx-zy*zy+cox;
zy=2*zx*zy+coy;
zx=tempx;
colorcounter=colorcounter+1;
betrq=zx*zx+zy*zy;
}
if (betrq<bailout) /*draw black pixel at x,y*/;
else /*draw white pixel at x,y*/);
}
}
system:
vc++: visual studio 6.0
c++builder 6 enterprise
windows xp home sp1
intel pentium m (centrino) 1400mhz
"PDQBach" <po*****@freenet.de> wrote...im a visual c++ und borland c++builder newbie.
i have witten a simple mandelbrot algorithm and compiled it with both
vc++ (mfc) and cbuilder (vcl) (same code besides the drawing part).
the vc++ version is twice! as fast in release mode. in debug mode its
as fast as cbuilder. it seems i cant get cbuilder to compile a real
release version. when i check "Project options:compiler:release" it
even gets slower than debug! i have played around a bit with the
advanced compiler options without any result. i also dropped the
drawing part, supposing that it causes slowdown somehow. the cbuilder
version is not faster than the same code on delphi 7 (maybe the same
problem). what can i do? i cant believe cbuilder (and delphi) to be
that much slower than vc++. i think its just a problem of finding the
right compiler options.
Right. And to solve it you need to post to the C++ Builder newsgroup
instead of C++ language one. You don''t have a _language_ problem.
Your problem, as you so precisely determined, is in finding the right
compiler options. Try borland.public.cppbuilder.* hierarchy.
Victor
po*****@freenet.de (PDQBach) wrote in message news:<6f**************************@posting.google. com>...Hello,
im a visual c++ und borland c++builder newbie.
i have witten a simple mandelbrot algorithm and compiled it with both
vc++ (mfc) and cbuilder (vcl) (same code besides the drawing part).
the vc++ version is twice! as fast in release mode. in debug mode its
as fast as cbuilder.
It''s off-topic, but this is fairly typical -- as a general rule,
Borland compilers optimize relatively poorly. With some work, you can
probably improve it somewhat, but chances are it''ll remain somewhat
slower anyway.
Later,
Jerry.
--
The universe is a figment of its own imagination.
Sorry for beeing offtopic. thanks for the answer.
<but chances are it''ll remain somewhat slower anyway.
i wouldnt call twice as fast somewhat. i prefer bcb for the ease of
use but such differences are inacceptable. i get the same results with
the following:
#include "stdafx.h"
#include <time.h>
#include <conio.h>
#include <iostream>
using namespace std;
void main() {
clock_t beg;
double j;
beg = clock();
for (double i=0; i<200000000; ++i) j = i*1000000;
int dif = clock()-beg;
cout << dif << endl;
getch();
i think theres nothing to optimize? how cant bcb optimizer screw up
such simple things? (sorry for continuing an offtopic thread)
这篇关于速度vc ++与c ++构建器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!