|
Hi
As an optimization for my app, I plan to incorporate some lookup tables into my class for functions such as since, power-of, etc. I have some questions though regarding how I can accomplish this:
1. Since the lookup table will clearly be shared among all objects of that class, where's the best way to place the lookup tables? I am thinking of defining them as static private members. This means that the lookup table will be initiated once during the first instantiation of the class and not during subsequent instantiation, doesn't it? Or is there some better place to put the lookup tables?
2. I am wondering though, will lookup table provide performance improvement over ordinary calculation for simple arithmetic such as power of two?
Thanks!
|
|
|
|
|
I did only some tests with SQRT(x)
LookupTable (source taken from NVIDIA)
sqrt function from the CRT
sqrt with the FPU
and the winner is.... FPU!
the LookUp table was the slowest version!
|
|
|
|
|
Lookup tables can be faster, depends on your needs, and your CPU. The CPU will calculate out to as many decimals as it can, if the first thing you do after getting an answer is round to the nearest intiger, then the lookup table is likely to be faster. However there are issues of cache that make it really hard to say. The larger the table the less advantage it has. (most operations you lookup are tight loops that can run entirelly in cache on a modern CPU with FEW stalls, while searching the table means a pipeline stall while loading the correct value from memory.
Go back a few generations and try to run on a 8088 CPU and the lookup table will scream. No FPU, and even if there was, memory access compared to CPU cycles is a lot cheaper However memory available is much less so you might not have room for the table.
In fact the faster answer might depend on if you are using a celeron, PPC, P4, or athalon just to name a full current CPUs. How portable do you need to be?
One question: I assume you are not doing premature optimization. That is your have your app running, it is too slow on the targeted CPU, and your profiler has determined that these operations are taking a lot of time. Remember, if the operation you are optimizing takes 0.1% of the CPU time no optimization can make a significant difference no matter how good. If it takes 50% of your CPU time you can make a big difference.
|
|
|
|
|
I am using the listview control from mscomctl.ocx in an MFC dialog.
When I right click on an item in the control, I find that the parent window(the dialog box)receives TWO WM_CONTEXTMENU messages, instead of one. When I click on an empty are of the control where there is no item yet, only one WM_CONTEXT message is generated.
What is the reason for this? Anyway to fix this?
thanks
Man Learns from History that he never learns from History
|
|
|
|
|
How to put more than one Toolbar in a single document MFC application?
How active it? http://paginas.terra.com.br/informatica/souza.bruno/toolbar.jpg
Thanks.
sdfs
|
|
|
|
|
Try to search for
CFrameWnd::DockControlBar( CControlBar * pBar, UINT nDockBarID = 0, LPCRECT lpRect = NULL );
usage.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
hi:
my application have five module,and i switch them with dialog like propertysheet.there is a setup modul that set system parameter.now,i want to know whether the data in setup-module dialog have been modified when i switch to another module automaticly(because i want to ask user whether to save the modification when data are modified,or else not).I dont want to set duty-mark for every control and only check whether the dialog-data have been modified(if i can).could u give me some suggestion.
thank u!
best regards!
Paul
|
|
|
|
|
The article at http://www.codeproject.com/cpp/checksum.asp[^] gives a decent overview of using checksums to see if a dialog (property page) has been modified. I use a modified version of it in one of my apps. I use a CRC32 checksum instead of the one provided in the article.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
i need to use some CEdit member functions on an edit box. but how do i access these? i guess i need a pointer to the edit box control, but how do i obtain it? i tried CWnd::GetDlgItem() but it returns a pointer to a CWnd object so i can't access CEdit member functions such as LineScroll(). i would appreciate ANY help.
|
|
|
|
|
If the control ID you pass to CWnd::GetDlgItem() references an edit control, then you can just cast the return value to a pointer to a CEdit . This works with any other type of control also.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks man. Never thought of that.
|
|
|
|
|
|
cadejohx wrote:
i guess i need a pointer to the edit box control, but how do i obtain it? i tried CWnd::GetDlgItem() but it returns a pointer to a CWnd object...
Save yourself some aggravation and use a CEdit member variable instead.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I want to change the default font in the dialog,for example:Arail.what should I do?
|
|
|
|
|
You can change it in your dialog resource properties.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
i see some program when login dialog end and follow a image that is fit for the application program content coming out for a while,but i dont know how to realize it,please give me some instruction ?thx all
|
|
|
|
|
I think what you are looking for is a splash screen. Try searching splash screen in codeproject. It is by the way not difficult to write your own.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
in my dialog there is a net address i want to realize hyperlinker when clicking it,if i dont write class specially for it,is there a more simpler way to solve it?
|
|
|
|
|
|
such as :extern CDatabase db;
CString sql1,sql2;
....
sql1=" ....";
db.ExecuteSQL(sql);
.....
sql2="...";
db.ExecuteSQL(sql);
....
|
|
|
|
|
You can call as many ExecuteSQL statements as you like given that the sql is a valid sql statement.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hello All, I have client and server programs. They used NamedPipe to communicate.
Here little bit about what each program does.
Server:
- has 2 buttons, print and stop
- Once the print button get pressed, create the thread and call the thread function.
here the thread function,
<br />
UINT PrintingThreadFunction(LPVOID lParam)<br />
{ <br />
CServerDlg *s = ((CServerDlg *)lParam);<br />
s->m_smain.OpenNewPipe(); <br />
while(!stopprinting)<br />
{ <br />
s->m_smain.ClientPrinting();
if(stopprinting == (int)YES)<br />
{<br />
s->m_smain.CloseThePipe(); <br />
break;<br />
}<br />
} <br />
stopprinting = (int)NO;
return (0);<br />
}<br />
The ClientPrinting() calls ConnectNamedPipe() which waits for the client to connect and then once the client connect to the pipe, it returns.
Client:
Client gets the file name from database and print it out. Then send the file name to Server using the same pipe.
Server has no problem Client's getting connected and sending a printed file name for 9 times. But at 10th time, Server get error message at ConnectNamePipe() which is
Unhandled exception at 0x0043e4cb in Server.exe: 0xC0000005: Access violation reading location 0x000000e4.
How can I eliminate this error?
I am thinking of using PostMessage(). But how the program also listen to the user click on Stop button?
Is stopping what the programs is doing for 10 seconds so the user can click on the quit button will help?
Thank you
|
|
|
|
|
I am thinking of using PostMessage(). But how the program also listen to the user click on Stop button?
Not sure of what the "stopprinting" is but would suggest to use event instead like this
<br />
if(WaitForSingleObject(<br />
yourStopEventHandle,<br />
INFINITE<br />
)== WAIT_OBJECT_0)<br />
{<br />
}<br />
check the event tutorial avail.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Having trouble getting this to work.
Need to control backlight level of LCD display.
Followed instructions for IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS and not getting any errors, but not getting any 'levels' back either.
Has anyone else tried using this API yet?
|
|
|
|
|
Hi !
I have to variables of type long. now i need to exponent the first with the second and then modulus a third long. how can i realize this ???
please Help
MFG
RedDragon2k
Unix and C are the ultimate computer viruses.
Visit me: www.programming.info.ms
|
|
|
|