VC8 program writing to cout much slower than VC6 program

J

Julian

hi, i have the following piece of code in a program compiled using both VC8
and VC6. it basically just writes out two arrays to cout.
the VC6 program takes about 4 seconds to go through that bit of code whereas
the VC8 program takes almost 18 seconds !
can someone tell me why this is so ? is this common?

thanks,
Julian.

(numberOfEquations= 15711)

int ic;
ic=0;
for(int j=0; j<numberOfEquations; j++)
{ic +=1;
cout<<loadVector[j]<<FORMAT;
if(ic==10) { ic=0; cout<<endl;}
}cout<<endl;
cout<<"pseudoLoadVector"<<endl;
ic=0;
for( j=0; j<numberOfEquations; j++)
{ic +=1;
cout<<pseudoLoadVector[j]<<FORMAT;
if(ic==10) { ic=0; cout<<endl;}
}cout<<endl;
 
B

Bruno van Dooren [MVP VC++]

hi, i have the following piece of code in a program compiled using both
VC8 and VC6. it basically just writes out two arrays to cout.
the VC6 program takes about 4 seconds to go through that bit of code
whereas the VC8 program takes almost 18 seconds !
can someone tell me why this is so ? is this common?

thanks,
Julian.

(numberOfEquations= 15711)

int ic;
ic=0;
for(int j=0; j<numberOfEquations; j++)
{ic +=1;
cout<<loadVector[j]<<FORMAT;
if(ic==10) { ic=0; cout<<endl;}
}cout<<endl;
cout<<"pseudoLoadVector"<<endl;
ic=0;
for( j=0; j<numberOfEquations; j++)
{ic +=1;
cout<<pseudoLoadVector[j]<<FORMAT;
if(ic==10) { ic=0; cout<<endl;}
}cout<<endl;

Maybe an obvious question, but were both release builds?

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
R

Roman Ziak

Julian said:
hi, i have the following piece of code in a program compiled using both VC8
and VC6. it basically just writes out two arrays to cout.
the VC6 program takes about 4 seconds to go through that bit of code whereas
the VC8 program takes almost 18 seconds !
can someone tell me why this is so ? is this common?

thanks,
Julian.

(numberOfEquations= 15711)

int ic;
ic=0;
for(int j=0; j<numberOfEquations; j++)
{ic +=1;
cout<<loadVector[j]<<FORMAT;
if(ic==10) { ic=0; cout<<endl;}
}cout<<endl;
cout<<"pseudoLoadVector"<<endl;
ic=0;
for( j=0; j<numberOfEquations; j++)
{ic +=1;
cout<<pseudoLoadVector[j]<<FORMAT;
if(ic==10) { ic=0; cout<<endl;}
}cout<<endl;

Maybe this is a problem with the speed of console. Did you take those
readings on the same computer ?

My Windows computer at work for some reason is terribly slow writing to
the console (in Windows). It's a Pentium 4 2.6G HT but you can almost
see the console refreshing from top to bottom when scrolling.
 
J

Jochen Kalmbach [MVP]

Hi Julian!
hi, i have the following piece of code in a program compiled using both VC8
and VC6. it basically just writes out two arrays to cout.
the VC6 program takes about 4 seconds to go through that bit of code whereas
the VC8 program takes almost 18 seconds !

Is the VC6 also using the multi-threaded CRT?
Also there is a small performance hit in VC8; which will be seen in
"non-real-world" test cases as your example...
See:
http://www.codeproject.com/cpp/improved2005crt.asp

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
G

Guest

Hi Jochen,

A nice article, thanks. Just a small note:
You probably meant x64 there. IA-64 is Itanuim.
Intel calls it's AMD64 compatible processors "Intel 64" - as they say,
to avoid confusion...

Regards,
-PA
 
J

Jochen Kalmbach [MVP]

Hi Pavel!
A nice article, thanks. Just a small note:
You probably meant x64 there. IA-64 is Itanuim.
Intel calls it's AMD64 compatible processors "Intel 64" - as they say,
to avoid confusion...

I don't understand what is confusing you...

The "bug" is present in x86 and IA64 implementation of the CRT.

It is *not* present in x64!

By the way: The problem is solved in SP1!

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
J

Julian

Bruno van Dooren said:
hi, i have the following piece of code in a program compiled using both
VC8 and VC6. it basically just writes out two arrays to cout.
the VC6 program takes about 4 seconds to go through that bit of code
whereas the VC8 program takes almost 18 seconds !
can someone tell me why this is so ? is this common?

thanks,
Julian.

(numberOfEquations= 15711)

int ic;
ic=0;
for(int j=0; j<numberOfEquations; j++)
{ic +=1;
cout<<loadVector[j]<<FORMAT;
if(ic==10) { ic=0; cout<<endl;}
}cout<<endl;
cout<<"pseudoLoadVector"<<endl;
ic=0;
for( j=0; j<numberOfEquations; j++)
{ic +=1;
cout<<pseudoLoadVector[j]<<FORMAT;
if(ic==10) { ic=0; cout<<endl;}
}cout<<endl;

Maybe an obvious question, but were both release builds?

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"

yeah, i compared the two release builds against each other and the two debug
builds against each other.. same behavior. (on the same computer)
 
J

Julian

Roman Ziak said:
Julian said:
hi, i have the following piece of code in a program compiled using both
VC8
and VC6. it basically just writes out two arrays to cout.
the VC6 program takes about 4 seconds to go through that bit of code
whereas
the VC8 program takes almost 18 seconds !
can someone tell me why this is so ? is this common?

thanks,
Julian.

(numberOfEquations= 15711)

int ic;
ic=0;
for(int j=0; j<numberOfEquations; j++)
{ic +=1;
cout<<loadVector[j]<<FORMAT;
if(ic==10) { ic=0; cout<<endl;}
}cout<<endl;
cout<<"pseudoLoadVector"<<endl;
ic=0;
for( j=0; j<numberOfEquations; j++)
{ic +=1;
cout<<pseudoLoadVector[j]<<FORMAT;
if(ic==10) { ic=0; cout<<endl;}
}cout<<endl;

Maybe this is a problem with the speed of console. Did you take those
readings on the same computer ?

My Windows computer at work for some reason is terribly slow writing to
the console (in Windows). It's a Pentium 4 2.6G HT but you can almost
see the console refreshing from top to bottom when scrolling.

yes, readings were from the same computer.
its a P4 2Ghz, 1GB RAM
 
J

Julian

Jochen Kalmbach said:
Hi Julian!


Is the VC6 also using the multi-threaded CRT?
Also there is a small performance hit in VC8; which will be seen in
"non-real-world" test cases as your example...
See:
http://www.codeproject.com/cpp/improved2005crt.asp
earlier, the VC6 version was single-threaded.
After reading your post, I rebuilt the VC6 version as Multi-threaded DLL
(which is what the VC8 version is) but I still get the same performance
issue.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top