Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > speed vc++ vs. c++builder

Reply
Thread Tools

speed vc++ vs. c++builder

 
 
PDQBach
Guest
Posts: n/a
 
      04-18-2004
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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      04-18-2004
"PDQBach" <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
 
Jerry Coffin
Guest
Posts: n/a
 
      04-19-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (PDQBach) wrote in message news:<(E-Mail Removed). 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.
 
Reply With Quote
 
PDQBach
Guest
Posts: n/a
 
      04-19-2004
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)
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      04-19-2004
PDQBach <(E-Mail Removed)> spoke thus:

(followups set)

> Sorry for beeing offtopic. thanks for the answer.


I've crossposted this to what I believe to be the appropriate Borland
group, because as noted it's offtopic for clc++, and I as a Borland
user have some interest in the answer. You can read the Borland group
using newsgroups.borland.com as your news server, if the one you're
using now doesn't carry the Borland groups.

(nothing trimmed, although some comments added)

>>but chances are it'll remain somewhat slower anyway.
>>[compared to VC++]

> 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() {

^^^^
This should be int for a standard C++ program, although I don't know
what bcc thinks about it.

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


(I don't believe OP specified his BCB version - I'd specifically be
interested in a BCB 4.0 answer.)

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
 
Reply With Quote
 
Kevin Goodsell
Guest
Posts: n/a
 
      04-19-2004
[Back to comp.lang.c++ for this comment.]

Christopher Benson-Manica wrote:
>
>
>>void main() {

>
> ^^^^
> This should be int for a standard C++ program, although I don't know
> what bcc thinks about it.


If it thinks anything other than "wrong", then it's not
standard-compliant. Unlike C, C++ does not permit alternative
implementation-defined forms for main() where the return type is not
int. In other words, implementation-defined forms are allowed, but they
must return int.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      04-19-2004
In comp.lang.c++ Kevin Goodsell <(E-Mail Removed)> wrote:

> If it thinks anything other than "wrong", then it's not
> standard-compliant. Unlike C, C++ does not permit alternative
> implementation-defined forms for main() where the return type is not
> int. In other words, implementation-defined forms are allowed, but they
> must return int.


So the parameters but not the return type are up for grabs?

Not to dwell (again) on bcc32, but some of our code has

void CMAIN( int argc, char **argv );

as the main function, through some (dubious?) magic that I don't
necessarily understand; hence my uncertainty regarding this issue.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
 
Reply With Quote
 
Kevin Goodsell
Guest
Posts: n/a
 
      04-19-2004
Christopher Benson-Manica wrote:

> In comp.lang.c++ Kevin Goodsell <(E-Mail Removed)> wrote:
>
>
>>If it thinks anything other than "wrong", then it's not
>>standard-compliant. Unlike C, C++ does not permit alternative
>>implementation-defined forms for main() where the return type is not
>>int. In other words, implementation-defined forms are allowed, but they
>>must return int.

>
>
> So the parameters but not the return type are up for grabs?


That seems to be the case. Although, I don't think a diagnostic is
required for an incorrect main() return type. I should have mentioned
that before.

>
> Not to dwell (again) on bcc32, but some of our code has
>
> void CMAIN( int argc, char **argv );
>
> as the main function, through some (dubious?) magic that I don't
> necessarily understand; hence my uncertainty regarding this issue.
>


Scary. Here's hoping that elsewhere in your code, you have something
like this:

int main(int argc, char **argv)
{
CMAIN(argc, argv);

if (some_error_state())
{
return EXIT_FAILURE;
}
else
{
return EXIT_SUCCESS;
}
}

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
 
Reply With Quote
 
Old Wolf
Guest
Posts: n/a
 
      04-19-2004
(E-Mail Removed) (PDQBach) wrote in message news:<(E-Mail Removed). com>...
> Sorry for beeing offtopic. thanks for the answer.
>
> 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)


Let me rewrite your program, removing non-standard code and
removing lines which have no effect (something that an optimiser
would do):

#include <iostream>
#include <ctime>
int main()
{
clock_t beg = clock();
int dif = clock() - beg; /* i'm not sure this is 100% safe */
std::cout << dif << std::endl;
return 0;
}

So I suppose your program is just seeing what the resolution of
the clock function is.
 
Reply With Quote
 
Siemel Naran
Guest
Posts: n/a
 
      04-20-2004
"PDQBach" <(E-Mail Removed)> wrote in message

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


Variable j is not used, so the for loop can be optimized away. Maybe MSVC
does this optimization? Check out the assembly. Try this variation too
where 'j' is used:

cout << j << ' ' << dif << endl;

In addition, I think Borland uses STLPort iostreams, which may not as
optimized as MSVC iostreams.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reported Wireless speed w/ repeater 7-9x Measured Speed Lance Wireless Networking 0 10-31-2004 09:31 PM
I need speed Mr .Net....speed Ham ASP .Net 6 10-29-2004 08:04 AM
speed speed speed a.metselaar Computer Support 14 12-30-2003 03:34 AM
java tool to test disk i/o, processor speed, and network speed efiedler Java 1 10-09-2003 03:36 PM
USB High Speed against USB Non High Speed DannyD1355 Computer Support 1 09-07-2003 02:59 AM



Advertisments