Click here to Skip to main content
15,908,015 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: obj versus &obj - performance test Pin
toxcct7-Oct-05 2:47
toxcct7-Oct-05 2:47 
GeneralRe: obj versus &obj - performance test Pin
ddmcr7-Oct-05 2:53
ddmcr7-Oct-05 2:53 
GeneralRe: obj versus &obj - performance test Pin
toxcct7-Oct-05 2:58
toxcct7-Oct-05 2:58 
GeneralRe: obj versus &obj - performance test Pin
ddmcr7-Oct-05 3:06
ddmcr7-Oct-05 3:06 
AnswerRe: obj versus &obj - performance test Pin
toxcct7-Oct-05 3:15
toxcct7-Oct-05 3:15 
GeneralRe: obj versus &obj - performance test Pin
Maximilien7-Oct-05 3:19
Maximilien7-Oct-05 3:19 
GeneralRe: obj versus &obj - performance test Pin
ddmcr7-Oct-05 3:24
ddmcr7-Oct-05 3:24 
AnswerRe: obj versus &obj - performance test ( edited with more results : Pin
Maximilien7-Oct-05 2:59
Maximilien7-Oct-05 2:59 
indeed, I tried just with an empty Add function, and it take twice as much time calling 1000000 times the function when using references.

( edited : ok I tried again, with a bigger iteration count, this is the code I use ( CProfiler can be found here on CP ).
void CtestCloseView::OnTataToto()
{
        CString x = "457235872349857348957238945723894579234896234789563";
        CString y = "573489573894573894579234852378456782345683475683746";

	CProfiler profiler;
	__int64 ptime = 0;
	profiler.ProfileStart(LOGNONE);

	for ( int i = 0; i < 8000000; i++ )
	{
		AddMe( x, y );
	}	
	ptime = profiler.ProfileEnd();
	double dd = profiler.SecsFromTicks(ptime);
	CString s1;
	s1.Format( "CtestCloseView::OnTataToto(1) :  %5.5f seconds\n", dd );
	TRACE( s1 );

	profiler.ProfileStart(LOGNONE);

	for ( int i = 0; i < 8000000; i++ )
	{
		AddMe2( x, y );
	}	
	ptime = profiler.ProfileEnd();
	dd = profiler.SecsFromTicks(ptime);
	s1;
	s1.Format( "CtestCloseView::OnTataToto(2) :  %5.5f seconds\n", dd );
	TRACE( s1 );

}


void CtestCloseView::AddMe( CString s1, CString s2 )
{
}

void CtestCloseView::AddMe2( const CString& s1, const CString& s2 )
{
}


The result are ( with 8000000 iterations ) :

CtestCloseView::OnTataToto(1) : 6.39813 seconds
CtestCloseView::OnTataToto(2) : 1.27944 seconds

and with 20000000 iterations :

CtestCloseView::OnTataToto(1) : 15.96244 seconds
CtestCloseView::OnTataToto(2) : 3.19041 seconds

which shows that I was wrong in my first assesment, and passing by reference will take less time.



Maximilien Lincourt
Your Head A Splode - Strong Bad

-- modified at 9:21 Friday 7th October, 2005
GeneralRe: obj versus &amp;amp;obj - performance test Pin
ddmcr7-Oct-05 3:02
ddmcr7-Oct-05 3:02 
GeneralRe: obj versus &amp;amp;obj - performance test ( edited with more results : Pin
ddmcr7-Oct-05 4:17
ddmcr7-Oct-05 4:17 
AnswerRe: obj versus &amp;obj - performance test Pin
S. Senthil Kumar7-Oct-05 3:19
S. Senthil Kumar7-Oct-05 3:19 
AnswerRe: obj versus &amp;obj - performance test Pin
Tim Smith7-Oct-05 3:56
Tim Smith7-Oct-05 3:56 
QuestionCStatic Drawing Pin
Jagadeesh VN7-Oct-05 1:45
Jagadeesh VN7-Oct-05 1:45 
QuestionMenu border Pin
hatemtaleb7-Oct-05 1:38
hatemtaleb7-Oct-05 1:38 
AnswerRe: Menu border Pin
toxcct7-Oct-05 1:41
toxcct7-Oct-05 1:41 
GeneralRe: Menu border Pin
hatemtaleb7-Oct-05 1:48
hatemtaleb7-Oct-05 1:48 
AnswerRe: Menu border (edited) Pin
toxcct7-Oct-05 1:52
toxcct7-Oct-05 1:52 
GeneralRe: Menu border (edited) Pin
hatemtaleb7-Oct-05 2:13
hatemtaleb7-Oct-05 2:13 
QuestionEdit boxes Interaction Pin
swaapu7-Oct-05 1:32
swaapu7-Oct-05 1:32 
QuestionRe: Edit boxes Interaction Pin
David Crow7-Oct-05 3:15
David Crow7-Oct-05 3:15 
AnswerRe: Edit boxes Interaction Pin
swaapu7-Oct-05 19:23
swaapu7-Oct-05 19:23 
QuestionEdit boxes Interaction Pin
swaapu7-Oct-05 1:32
swaapu7-Oct-05 1:32 
QuestionDrawTextEx not working properly when printing on Windows 98 Pin
Paul Vickery7-Oct-05 1:24
professionalPaul Vickery7-Oct-05 1:24 
AnswerRe: DrawTextEx not working properly when printing on Windows 98 Pin
KaЯl7-Oct-05 1:54
KaЯl7-Oct-05 1:54 
AnswerRe: DrawTextEx not working properly when printing on Windows 98 Pin
Paul Vickery7-Oct-05 5:18
professionalPaul Vickery7-Oct-05 5:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.