|
I think you'll have to show some more code. It's not clear how you have actually 'found' any file since there has to be at least one call to FindNextFile. Also, I'd check the return value of GetLastWriteTime() just to be sure that it returns TRUE.
|
|
|
|
|
Did you check your unix system records file times with better than 1 minute resolution?
just log in and use some interactive commands such as "ll".
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hello everyone,
I read MSDN document about reserve method of vector, but I can not find answers to the following 2 questions after reading it,
1. if we reserve 10,000 size, will the memory actually be occupied 10,000 size (like committed memory of Windows Virtual Memory management) or the memory will just be reserved for future use (like reserved memory of Windows Virtual Memory management);
2. Will reserve method of vector improve performance? If yes, could anyone share some experiences please?
If reserve method has any additional benefits beyond performance, please also let me know.
thanks in advance,
George
|
|
|
|
|
George_George wrote: 1. if we reserve 10,000 size, will the memory actually be occupied 10,000 size (like committed memory of Windows Virtual Memory management)
Yes.
George_George wrote: 2. Will reserve method of vector improve performance?
It may if you are adding elements at the end.
|
|
|
|
|
Thanks Nemanja,
regards,
George
|
|
|
|
|
When n supposes an expansion in capacity, a reallocation happens during the call to this function, granting that no further automatic reallocations will happen because of a call to vector::insert or vector::push_back until the vector size surpasses at least n
link[^]
|
|
|
|
|
Thanks led,
I can understand reserve will improve performance of push_back, but how will reserve improve the performance of insert? Seems you (or the article) means that reserve will improve the performance of both insert and push_back.
regards,
George
|
|
|
|
|
George_George wrote: but how will reserve improve the performance of insert?
again, only if the insert does not cause the current allocation to be exceeded. That is the basis of the optimization, the minimization of heap allocations. On an insert if adequate memory has already been allocated by the reserver() call, then a memmove followed by the assignment of the inserting value could accomplish the insert.
|
|
|
|
|
Thanks led,
Your reply is clear.
regards,
George
|
|
|
|
|
In terms of Virtual Memory it will be committed. This doesn't mean it won't end up being paged out to a swap file/page file though.
Any perfromance improvement will depend on how you're using the vetor and on what else the machine is doing. In general if you're working with a larger number of items but only 1 at a time, adding and deleting more or less at random then reserving will give you the greatest performance gain. If you're performing entirely linear operations, add 10,000 items, then iterate over them a few times in order, then free them, it will give you very little or nothing.
Testing memory performance is tricky because new and delete do 50x and more as much work in Debug as in Release. Other factors like low memory or task switching or heavy use of non-paged pool in comms apps can easily swamp and distort your figures beyond use. Reserving of course also has the down side of using more memory than you actually need. It all depends whether you're optimising for memory footprint or speed. Of course you could write your own heap manager and override the global new and delete operators. If it's good enough for the .NET team it must be OK right?
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks Matthew,
I do not quite agree with your following scenarios,
Please feel free to correct me if I am wrong?
1. In the following scenario, you mentioned there will be performance improvement,
Matthew Faithfull wrote: In general if you're working with a larger number of items but only 1 at a time, adding and deleting more or less at random then reserving will give you the greatest performance gain.
Suppose we reserved a large number of memory, but we only do small operation (e.g. adding/deleting one item).
Why will performance be improved? On the contrary, I think the following scenario you mentioned below will improve performance if we reserve a large number of memory in advance.
2. I think in the following scenario, since we reserved a large number of memory in advance, so the performance should be improved. But why you mentioned there will be almost no performance improvements?
Matthew Faithfull wrote: If you're performing entirely linear operations, add 10,000 items, then iterate over them a few times in order, then free them, it will give you very little or nothing.
regards,
George
|
|
|
|
|
Hi All,
I would like to post a xml string to a http server & in turn the http server is supposed to return another xml as response. In dot net I found WebRequest & WebResponse classes works as I expect, but I need to do it in VC++. I have tried using CHttpConnection of MFC(wininet) & IXmlHttpRequest, can somebody suggest the appropriate option.
Thanks.
|
|
|
|
|
Who am I, I don't Know wrote: I have tried using CHttpConnection of MFC(wininet)
That should work.
|
|
|
|
|
Following is the code lines I am trying
CString cstrServer = L"SomeServer";
CString cstrObject = L"SomePage.aspx";
CInternetSession HttpSession;
CHttpConnection *pHttpConnection = HttpSession.GetHttpConnection(cstrServer, nPort, NULL, NULL);
if(pHttpConnection)
{
CHttpFile* pHttpFile = pHttpConnection->OpenRequest(L"POST", cstrObject);
//I supposed to do something here, but I receive CInternetFile* in CHttpFile NULL
}
Unable to get the problem.
|
|
|
|
|
Are you using an example or tutorial? If so, provide a link. If not you should, there are some on MSDN
|
|
|
|
|
hi everyone,
i have a problem, i'm using a editable combo box inmy project and also i have added an event to combobox that when a user keys in any data it will check for the data i the database,if the data is there the data will be listing in the combobox.
My problem is after updating the combobox the cursor postion will be at the start(like "|100").I need the cursor should be postioned in the last of line.
please reply with some samples or links,please...
||SnAkeBed||
|
|
|
|
|
Asuming m_Combo1 is the variable of class CComboBox try
int tLen = m_Combo1.GetLBTextLen(m_Combo1.GetCurSel());<br />
m_Combo1.SetEditSel(tLen,tLen);
I hope it helps
|
|
|
|
|
thankyou for kind reply,
But it was not working...
|
|
|
|
|
thankyou for kind reply,
But it was not working...
||SnAkeBed||
|
|
|
|
|
SnaKeBeD wrote: But it was not working...
Which means what?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
try this, it work for me.
In a MFC dialog app , add a ComboBox, add a control variable m_Combo1 for it.
in the CBN_EDITCHANGE message map the metod: OnCombo1EditChange
In the body copy the folowing code
<br />
void CMFC1Dlg::OnCombo1EditChange()<br />
{<br />
<br />
CString UserText;<br />
TCHAR AddText[12] = _T("New Element");<br />
CWnd * pEdit = m_Combo1.GetWindow( GW_CHILD ); <br />
ASSERT( pEdit );<br />
pEdit->GetWindowText(UserText);<br />
if ( UserText.Compare(_T("New"))==0)<br />
{<br />
if (m_Combo1.FindString(-1,&AddText[0])==CB_ERR ) <br />
{<br />
m_Combo1.AddString(&AddText[0]);<br />
m_Combo1.SetCurSel(m_Combo1.FindString(-1,&AddText[0]));<br />
}<br />
int tLen = m_Combo1.GetLBTextLen(m_Combo1.GetCurSel());<br />
m_Combo1.SetEditSel(tLen,tLen); <br />
}<br />
}<br />
<br />
//Note CMFC1Dlg is the class for the dialog
Or take a look at:
http://www.codeproject.com/combobox/combocompletion.asp
|
|
|
|
|
thanks for your post,
this may be useful for me in future.
BTW, can you suggest me some technique in code project such that i can mark my favourites (like that of yours) such that i can refer them in future?
thank you.
|
|
|
|
|
What about the permalink (4th place "reply" and so on)
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
thanks for your reply,
but will the permalink adds the post to my favourites?
what i mean is, i should be able to see my favourites from any system. can you suggest in this regard?
and replying tthe interested post and finding them in my posts from my profile page will also do.
but i would have to reply them saying
"thank you and your post is useful for me in future"
which occupies unnecessary space in CP and this may also be in convinient to some members.
thank you.
|
|
|
|
|
Yes, make a try... if you use search for a message, there will be "?" and "search" keywords in the url on the navigator when you go to the selected one. But once you are in the message, if you press "permalink" then the navigator autoupdates itself and in the toolbar you will have an URL in absolute mode with the code ID of the forum and message. So if you add it in favourites or copy paste in a txt you will have the url to the message, although the board grows a lot.
I make it that way, take the permalink and then write down a short description in a txt, adding the link at the end. So I have the direction and something that helps me find the one I need.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|