Click here to Skip to main content
15,912,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Returning a value from a Worker Thread Pin
Tom Archer12-Jun-05 13:44
Tom Archer12-Jun-05 13:44 
GeneralRe: Returning a value from a Worker Thread Pin
Steve Messer12-Jun-05 16:38
Steve Messer12-Jun-05 16:38 
GeneralRe: Returning a value from a Worker Thread Pin
Tom Archer12-Jun-05 18:20
Tom Archer12-Jun-05 18:20 
Generalimage processing Pin
prabhathgk12-Jun-05 7:51
prabhathgk12-Jun-05 7:51 
GeneralRe: image processing Pin
DavidR_r12-Jun-05 9:41
DavidR_r12-Jun-05 9:41 
GeneralDelta time in mSec Pin
Ravi Bhavnani12-Jun-05 6:48
professionalRavi Bhavnani12-Jun-05 6:48 
GeneralSolved! Pin
Ravi Bhavnani12-Jun-05 7:34
professionalRavi Bhavnani12-Jun-05 7:34 
GeneralAre function calls that costly? Need help optimizing Pin
Budric B.12-Jun-05 6:32
Budric B.12-Jun-05 6:32 
Hi,
I'm writing some simple image processing functions such as gaussian blur etc. I have an image class to represent the data. I then used the following to benchmark how fast it runs:
<br />
	start = clock();<br />
	<br />
	for (int k = 0; k < 100; k++)<br />
	{<br />
//code<br />
	}<br />
<br />
<br />
	finish = clock();<br />
	double duration = (double)(finish - start) / CLOCKS_PER_SEC / 100;<br />

I find that my GetPixel() function is the cause of very slow performance. For example here's the code that I can benchmark:
<br />
	for (int i = 0; i < test.m_nHeight; i++)<br />
		{<br />
			for (int j = 0; j < test.m_nWidth; j++)<br />
			{<br />
				int value = test.m_pData[i*test.m_nHeight + j];  <br />
				//int value = test.GetPixel(i, j);<br />
			}<br />
		}<br />

If I access the value directly from the pointer I get duration = 0.0013 s. The other commented line of code gives me 0.012. That's 10 times slower!

I was hoping to wrap everything up nicely in a class, but it looks like that's not going to happen. Is it something I"m doing wrong, or just the way things are for function calls.

Also are there any suggestions you have on code optimization? Any articles? I would not like to start writing messy C code all wrapped up in one function for speed.

Thanks
GeneralRe: Are function calls that costly? Need help optimizing Pin
liquid_12-Jun-05 7:35
liquid_12-Jun-05 7:35 
GeneralRe: Are function calls that costly? Need help optimizing Pin
Budric B.12-Jun-05 7:52
Budric B.12-Jun-05 7:52 
GeneralRe: Are function calls that costly? Need help optimizing Pin
squidev12-Jun-05 7:44
squidev12-Jun-05 7:44 
GeneralRe: Are function calls that costly? Need help optimizing Pin
Tom Archer12-Jun-05 13:50
Tom Archer12-Jun-05 13:50 
GeneralRe: Are function calls that costly? Need help optimizing Pin
PJ Arends12-Jun-05 17:35
professionalPJ Arends12-Jun-05 17:35 
GeneralRe: Are function calls that costly? Need help optimizing Pin
Budric B.13-Jun-05 4:09
Budric B.13-Jun-05 4:09 
GeneralCapturing Sound Pin
Identity Undisclosed12-Jun-05 6:18
Identity Undisclosed12-Jun-05 6:18 
QuestionHow to remove the close button correctly in a rebar control? Pin
Dani10000112-Jun-05 5:08
Dani10000112-Jun-05 5:08 
QuestionWin32: IsDialog(HWND)? Pin
peterchen11-Jun-05 23:33
peterchen11-Jun-05 23:33 
AnswerRe: Win32: IsDialog(HWND)? Pin
Jack Puppy12-Jun-05 0:16
Jack Puppy12-Jun-05 0:16 
GeneralRe: Win32: IsDialog(HWND)? Pin
Jörgen Sigvardsson12-Jun-05 2:57
Jörgen Sigvardsson12-Jun-05 2:57 
GeneralRe: Win32: IsDialog(HWND)? Pin
peterchen12-Jun-05 3:49
peterchen12-Jun-05 3:49 
GeneralRe: Win32: IsDialog(HWND)? Pin
Jörgen Sigvardsson12-Jun-05 5:21
Jörgen Sigvardsson12-Jun-05 5:21 
GeneralRe: Win32: IsDialog(HWND)? Pin
Jack Puppy12-Jun-05 4:22
Jack Puppy12-Jun-05 4:22 
GeneralRe: Win32: IsDialog(HWND)? Pin
Jörgen Sigvardsson12-Jun-05 5:23
Jörgen Sigvardsson12-Jun-05 5:23 
GeneralRe: Win32: IsDialog(HWND)? Pin
Jack Puppy12-Jun-05 14:45
Jack Puppy12-Jun-05 14:45 
Generalfunction pointer on classfunctions Pin
tbrake11-Jun-05 22:45
tbrake11-Jun-05 22:45 

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.