Alex
2005-06-27 16:19:44 UTC
I know that this post should be in the Borland site (and it is) but I am
getting no luck there so I thought I'd ask here (don't laugh). We use both
Microsoft and Borland here (mostly MS but one project uses Borland C++
Builder 5). We have had many complaints from customers that parts of our
program run way too slow (our math calculations). So I made the following
test program:
double x, y, z, tot = 0.0;
for (int j = 0; j < 1000; ++j)
{
for (int k = 0; k < 1000000; ++k)
{
x = 2;
y = .5;
z = x * x / (y + 2);
tot += z;
}
}
Yes I know the code is totally inefficient. It IS suppose to be. I want the
compiler to work for me in this case. When I compile this in Borland debug
114 sec., in MS debug about 114, in Borland release (compiler
flags -O2, -O, -Ov, -OS, -ff) still about 114, MS 5 sec.. I couldn't believe
it. The problem is that the project IS in Borland, it has hundreds of
thousands of lines of calculations (in many many loops) and I'm stuck. It is
as if the loop optimization flag does not work (with no caculations, just
the loops and a counter, the time difference is still overwelming). I am
using the math coprocessor, I check. Have you heard of such time
differences? If so, have you heard how to improve such difference using the
Borland compiler? I feel that I must not be setting something correctly in
Borland but I don't know what. I have posted this in Borland newgroups too
but people just keep responding that the code is inefficient and I should
rewrite it in ASM. They are missing the point!!!! Any help would be greatly
appreciated. Thanks in advance. Alex
getting no luck there so I thought I'd ask here (don't laugh). We use both
Microsoft and Borland here (mostly MS but one project uses Borland C++
Builder 5). We have had many complaints from customers that parts of our
program run way too slow (our math calculations). So I made the following
test program:
double x, y, z, tot = 0.0;
for (int j = 0; j < 1000; ++j)
{
for (int k = 0; k < 1000000; ++k)
{
x = 2;
y = .5;
z = x * x / (y + 2);
tot += z;
}
}
Yes I know the code is totally inefficient. It IS suppose to be. I want the
compiler to work for me in this case. When I compile this in Borland debug
114 sec., in MS debug about 114, in Borland release (compiler
flags -O2, -O, -Ov, -OS, -ff) still about 114, MS 5 sec.. I couldn't believe
it. The problem is that the project IS in Borland, it has hundreds of
thousands of lines of calculations (in many many loops) and I'm stuck. It is
as if the loop optimization flag does not work (with no caculations, just
the loops and a counter, the time difference is still overwelming). I am
using the math coprocessor, I check. Have you heard of such time
differences? If so, have you heard how to improve such difference using the
Borland compiler? I feel that I must not be setting something correctly in
Borland but I don't know what. I have posted this in Borland newgroups too
but people just keep responding that the code is inefficient and I should
rewrite it in ASM. They are missing the point!!!! Any help would be greatly
appreciated. Thanks in advance. Alex