|
It's hard to know without more info about that Fn function and the parms it is accepting. Change the static lib implementation to a do-nothing function, so that you will be basically measuring the cost of doing the function call --maybe this sheds some light on the problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
FYI, here are the parameters:
<br />
void FnNew(const BYTE *pIn, const int inW, const int inH, BYTE *pOut, const int outW, const int outH, const int bpp)<br />
the static lib function has essentially the same params, except that they aren't "const" - they are treated as const, but not labelled as such. i tested this angle and got the same results, const or not.
-c
<font size=-2>
o(int O){putchar(O);}main(){float _[8],O,I=.05;char l;for(_[6]=15;_[6]<':';o
(10),_[5]=-'$'*I+_[6]++*I)for(_[7]=-5;_[7]<'@';_[4]=-'('*I+_[7]++*I,o(l?'?':':'))
for(*_=O=0,l=1;++l&&((_[2]=*_**_)+(_[3]=O*O)<4);O=*_*O+_[5]+O**_,*_=_[2]-_[3]+_[4]);}</font>
|
|
|
|
|
What happens if you replace the static lib "i.e. the reference" implementation with a do-nothing function? Still having worse results in "Max speed"?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
actually, no.
i had to make a new static lib to test this (don't have the source to the other lib with me). but, the do-nothing function with 100000000 reps takes the same amount of time regardless of how the calling app is optimized.
hmm.
-c
<font size=-2>
o(int O){putchar(O);}main(){float _[8],O,I=.05;char l;for(_[6]=15;_[6]<':';o
(10),_[5]=-'$'*I+_[6]++*I)for(_[7]=-5;_[7]<'@';_[4]=-'('*I+_[7]++*I,o(l?'?':':'))
for(*_=O=0,l=1;++l&&((_[2]=*_**_)+(_[3]=O*O)<4);O=*_*O+_[5]+O**_,*_=_[2]-_[3]+_[4]);}</font>
|
|
|
|
|
Maybe I didn't made myself clear enough... I'm asumming the do-nothing function still accepts the whole lot of parameters (even though it does nothing with them), right?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
yes. it's the same function signature - just nothing in the function.
-c
<font size=-2>
o(int O){putchar(O);}main(){float _[8],O,I=.05;char l;for(_[6]=15;_[6]<':';o
(10),_[5]=-'$'*I+_[6]++*I)for(_[7]=-5;_[7]<'@';_[4]=-'('*I+_[7]++*I,o(l?'?':':'))
for(*_=O=0,l=1;++l&&((_[2]=*_**_)+(_[3]=O*O)<4);O=*_*O+_[5]+O**_,*_=_[2]-_[3]+_[4]);}</font>
|
|
|
|
|
Chris Losinger wrote:
FYI, here are the parameters:
void FnNew(const BYTE *pIn, const int inW, const int inH, BYTE *pOut, const int outW, const int outH, const int bpp)
That explains it. Seven stack parameters using the IA32 architecture can be nothing but disaster. You wouldn't gain much by using "register" calling conventions either, since at four (or rather three in C++ functions) GPR's the optimizer can't actually help.
Try creating a struct that wraps your paramaters and do some re-testing. I'm sure you'll get the speed up again.
Note: Using MSVC you'd have to create auto-variables at the callee's site if you're using them more than once, else the MSVC optimizer often don't "cache" the values in registers, it frequently reloads them from the pointed-to object. I.e. do
void FnNew(const* pSmth)
{
const int inW = pSmth->inW;
... use inW multiple times ...
}
|
|
|
|
|
It could well be the kernel process scheduler. Well not so much that but say another program starts having a few page faults, in 5 seconds the kernel has switched so many threads and processes that this kind of thing could be affecting your timings. The best way is to do this over a longer period, say 30-60 seconds. As well as that make sure you have things like background file indexing etc turned off. It all makes a difference, and it could be that your thread is not getting its share of the time it wants. Ultimately the scheduler is based on heuristics that allow it to tune itself, and while its accurate most of the time, there’s not reason while it could not mess up for a second or two. Have your tried repeating the same thing – could be asking a stupid question. I’ll shut up.
|
|
|
|
|
sadly, the times are totally consistent and reproducable.
-c
<font size=-2>
main(){float _,l,O,I,o,x;char i;for(x=-1;x<1;x+=.05,putchar(10))
for(o=-2;o<.9;o+=.05,putchar(i?'?':':'),_=l=O=I=--(i=1))for
(;((O=_*_)+(I=l*l)<4)&++i;l=_*l*2+x,_=O-I+o);}
</font>
|
|
|
|
|
Hi,
As title.
I know that there are a few ZIP compression libraries either
freely or commercially available.
But I couldn't find RAR compression ones, simple source
codes, or even books about this compression algorithm
as I have the needs to handle RAR files in my program.
So, just wondered if someone knows it. Thanks
|
|
|
|
|
ykliu wrote:
But I couldn't find RAR compression ones, simple source
codes, or even books about this compression algorithm
as I have the needs to handle RAR files in my program.
<irony>
How odd, a commercial compression library with a proprietary compression algorithm isn't freely available.
Serisouly, since its proprietary you won't find any free implementations of it.
For free implementations I'd say that for fast compression I recommend you have a look at LZO. For reasonable time/space you should probably use zlib. For better compression you should probably have a look at bz2.
|
|
|
|
|
Hi:
I am sort of new to C++.
Suppose I created a CString array of n elements.
CString *someArray;
someArray = newCString[n];
Then further in the code I changed my mind and decided that n was too much and half of that will be enough.
Can I resize the array during run time WITHOUT losing the data in the first half of the array. In VB it's easily achieved using PRESERVE keyword. Is there an alternative in C++?
Thank you.
|
|
|
|
|
No there is not.
The best you can do is to allocate a new buffer, and copy all of the data from the first buffer into the second buffer. Delete the memory from the first buffer, then assign the pointer from the second buffer back to the first.
By the way, the VB method is just more convenient, not more effifient, underneath all of this work is done by VB as well, you just do not have to deal with it.
Good Luck!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
short answer to this particular question: use CStringArray. you can resize the array all you want.
not as short answer to this particular question: use std::vector<CString>. vectors are dynamic arrays, so you can resize them at will.
but, short answer to the general question "can i resize an array allocated with 'new'?": no.
-c
<font size=-2>
o(int O){putchar(O);}main(){float l[8],O,I=.05;char _;for(l[6]=15;l[6]<':';o
(10),l[5]=-'$'*I+l[6]++*I)for(l[7]=-5;l[7]<'@';l[4]=-'('*I+l[7]++*I,o(_?'?':':'))for
(*l=O=0,_=1;++_&&((l[2]=*l**l)+(l[3]=O*O)<4);O=*l*O+l[5]+O**l,*l=l[2]-l[3]+l[4]);}</font>
|
|
|
|
|
Ok. This is my code, iøm using the CreateDIalog function so i can use my Resource file to design the app:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
ghInstance = hInstance;
ghWnd = CreateDialog (hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, WndProc);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
but when i run the program, nothing appears.
Thanks all!
|
|
|
|
|
I guess you need to call ShowWindow(SW_SHOW) after create.
|
|
|
|
|
Cool it works now. But i can't move the window now... any ideas?
Thanks
|
|
|
|
|
Ensure that the dialog has a caption bar and your dialog proc is handles standard messages by calling the default handler. Any reason why you're using the Win32 API instead of MFC?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
yes, this is the procedure, i've placed brakepoints in it to make sure it enters it and it does:
BOOL CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch (wParam)
{
case ID_FILE_EXIT:
PostQuitMessage (0);
break;
}
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}
return (0L);
}
and the reason why i use it is because i think i have more control over my program, i don't like those embedded things, hope you understand me
|
|
|
|
|
Anonymous wrote:
and the reason why i use it is because i think i have more control over my program,
Imho, it's much easier to build GUIs using MFC. You get a lot of support from the framework.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I agree, but when you can use the Dialog designer with a non-MFC program i think it's better.
|
|
|
|
|
Anonymous wrote:
i think it's better
i've never heard someone using MFC ask why they can't move their dialog...
but, to each his own.
-c
<font size=-2>
o(int O){putchar(O);}main(){float l[8],O,I=.05;char _;for(l[6]=15;l[6]<':';o
(10),l[5]=-'$'*I+l[6]++*I)for(l[7]=-5;l[7]<'@';l[4]=-'('*I+l[7]++*I,o(_?'?':':'))for
(*l=O=0,_=1;++_&&((l[2]=*l**l)+(l[3]=O*O)<4);O=*l*O+l[5]+O**l,*l=l[2]-l[3]+l[4]);}</font>
|
|
|
|
|
My guess is that the move command does not reach the call to DefWindowProc.
If fact, if the command is not handled by your code (ID_FILE_EXIT in this case), then DefWindowProc should be called.
Thus you should add a default in the internal switch that will call DefWindowProc.
But according to MSDN, systems command like SC_MOVE are send as a WM_SYSCOMMAND message so it may be something else...
Philippe Mori
|
|
|
|
|
I already have a default case in my switch statement...:
BOOL CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch (wParam)
{
case IDC_OPENFILE:
OnOpenFile(hWnd);
break;
case ID_FILE_EXIT:
PostQuitMessage (0);
break;
}
break;
case WM_INITDIALOG:
OnInitApp(hWnd);
break;
case WM_DESTROY:
RegSave(hWnd);
PostQuitMessage (0);
break;
default:
return DefWindowProc (hWnd, uMsg, wParam, lParam);
}
return (0L);
}
i have also made breakpoints so see if the satement is executed, and it is..
|
|
|
|
|
Hey Guys
If i use an instance of a class in a funtion then deallocate it is it deallocated again when the function drops out. I only ask cos i keep getting a close handle again on my file access class at the end of my function even though i have already destructed the instance and haven't created another.
Peter
|
|
|
|
|