|
First, don't use strTemp. It is a total waste of time. All of those left operations are creating temp objects that just aren't needed.
if (szBuffer2 [0] != '.')
{
CNumberAndName *pEntry = new CNumberAndName ();
szBuffer [9] = 0;
pEntry ->m_strRoutingNumber = szBuffer;
szBuffer [11+36] = 0;
pEntry ->m_strBankName = &szBuffer [11];
paBankArray ->Add (pEntry);
}
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
thanks a bunch.. seems that i need to learn how char arrays work, i always use cstrings because they are easy for me to use.. thanks for the code.. now all i have to do is figure out what you are doing with the char arrays
thanks again for everyones help!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
The "szBuffer [0] == '.'" is just checking to see if the first character is a '.'.
The szBuffer [9] = 0; is splitting the string into two parts. The first part starts at szBuffer [0] and is 9 characters long. The second part starts at szBuffer [10] and contains the rest of the string. This allows you to copy the first part of the string into your destination.
The szBuffer [11+36] = 0; is doing the same thing. But now we have three strings.
What this does is remove the need to allocate a new buffer to hold the string, copy that string into the new buffer, and then extra elements from the string piece by piece. By directly operating on the original string, we avoid a fair amount of overhead.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Have a look for grep.c on the net, it is a UNIX tool, did a quick test on one of my files using it, 545,000 lines searching for a non existing string took 8 seconds on my 450mhz dual celeron. Oh I forgot to mention the file is c. 100MB
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
do you know how to implement CBaseControlWindow interface in IGraphBuilder ? plz, thnx u
|
|
|
|
|
I was experimenting with file IO times and discovered some peculiar results that I do not understand and thought mabye sombody could explain it to me.
I was testing the hypothesis that in file IO processing it is better to use a bigger buffer than a smaller one (I was thinking that the fastest way to perform large file IO was to read a disk sector at a time). To test this I performed the following test.
Test:
Copy one file on one drive to another file on another drive. To perform the copy I used VisualC++ 6.0 on a box running Win2k. I wrote a simple console app that just used fread() and fwrite() to and from the files on the different drives.
Results:
The results I got were shocking to me. I ran the code in debug mode first and discovered that on my hardware and a 120Mb file copy I obtainted the following times (in seconds) for each read/write buffer size:
1 byte = 128(s)
2 bytes = 112(s)
4 bytes = 104(s)
8 bytes = 100(s)
16 bytes = 99(s)
...
512K bytes = 99(s)
So there appeared to be a threashold at around 8 bytes above which buffer size makes no difference.
When I re-ran the code in Release mode with the optimizer set to maximize speed the results were much different:
1 byte = 120(s)
2 bytes = 120(s)
...
512K bytes = 120(s)
The "plateau" region went away and the curve flattened out. However the large buffer read times went up! This makes no sense to me!
Does anybody out there know what is going on here? I would appreciate any enlightenment.
Thanks!
|
|
|
|
|
First problem is that you are using fread/fwrite that include their own buffering. To better test raw performance, use ReadFile and WriteFile.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
I am having major thread problems in my application.
I am trying to set up our program so the threads don't run into each other (access the same file at the same time) and so they don't wait on each other forever.
I have been working on this for 2 weeks now and am nearly suicidal because it isn't working. I need a solution to replace what I have now. Please read everything below and respond if you are able to help out.
This is in a Doc/View structure. Basically, I need to know where to create the threads, what I should use for syncrhonization, where to wait, and where to set the threads/events/etc. as signalled. Thank you so much for your help!!
--Dan
/\/\/\
Right now, we have a thread for Action-S, for Action-A, and for Action-C.
Action-S accesses a file in memory and then updates a physical file.
Action-A accesses the same file in memory and updates a local file.
Action-C accesses the same physical file as Action-S and then locks down the main thread until a process is finished (the lockdown works fine - I don't need to worry about that).
All Action-S's and Action-A's only care about the actions for a particular file name. If the file "xyz" is open, Action-A for "xyz" does not care about what is happening for file abc (such as an Action-A for "abc").
For one file only, please refer to this diagram...
L P
\ / \
A\ S/ C\
\ / \
M W
"A" - Action-A (performs M then L)
"S" - Action-S (performs M then P)
"C" - Action-C (performs P then W)
"L" - Local File
"M" - File in Memory
"P" - Physical File
"W" - Process to Wait On.
"\" - a Thread
"/" - a Thread
|
|
|
|
|
The diagram again...
L P
\ / \
A\ S/ C\
\ / \
M W
|
|
|
|
|
Why do you need separate thread for each of you files? If I did not miss anything, for the same file there are no asynchronies actions possible, all threads have to wait for each other. Alternative solution would be to start thread for each of the files. Inside of the thread call the function for each action.
thread1
----"abc"------
| fL fP |
| \ / \ |
| fA\ fS/ fC\ |
| \ / \ |
| fM fW |
---------------
thread2
----"xyz"------
| fL fP |
| \ / \ |
| fA\ fS/ fC\ |
| \ / \ |
| fM fW |
---------------
thread3
----"bla"------
| fL fP |
| \ / \ |
| fA\ fS/ fC\ |
| \ / \ |
| fM fW |
---------------
|
|
|
|
|
Action-S and Action-A only wait for each other when accessing the file in memory. Then (if there are only these two threads), they can go about their business independently.
|
|
|
|
|
then use something like
HANDLE hEvent = CreateEvent(0, TRUE, TRUE, "abc");//note that we use filename to name the event
//just in case
if(WaitForSingleObject(hEvent, INFINITE) == WAIT_OBJECT_0 && ResetEvent(hEvent))//lock event on your behave
{
//... do your staff
SetEvent(hEvent);//let somebody else to continue
}
|
|
|
|
|
If you're just going to lock access,
you really want a mutex there though.
HANDLE hMutex=CreateMutex(0,FALSE,Filename);
WaitForSingleObject(hMutex,INFINITE);
ReleaseMutex(hMutex);
|
|
|
|
|
Unless you are using multiple processes you want to use a critical section, not a mutex. cs are much faster.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
Yeah, completely correct. As further overkill, the example
used a named object. I don't know if it really matters as
much as I am reluctant to create named objects when an
unnamed one will do, but I always prefer to limit my
exposure.
(oh yeah, which I did not do in that ex. )
|
|
|
|
|
I agree, event seemed like a simple alternative
|
|
|
|
|
I want Browse my dirs and open a text file (*.txt) and will view on my SDI Project.
On Editview is not Problem but by Listview Projekt is a Problem
I need a function to get a text file in SDI projekt
I need your help
THX.
|
|
|
|
|
You want to view the contents of a text file in a ListView?
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I will Open a Text File in MDI or SDI Projekt an view it.
the Text list will lock be after so
exemple of a Text File
DATE............TIME....LONG
03.01.03........18:45...00:03:42
05.01.03........19:11...00:04:06
08.01.03........19:29...00:01:32
09.01.03........15:56...00:04:52
later will be look that
THX
|
|
|
|
|
You will have to create a function to parse the text file to pull out those values then you will have to insert them into the correct rows and columns in your list..
There are plenty of articles on how to use the list control here at codeproject. If I just posted code you wouldn't learn anything. Try to do this by following examples and reading. If you get stuck post your problem and some code that you have tried and anyone would be glad to help you.
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
I have a file (it's an mpg), that I want to give it to few people..put it on their pcs, but I want to disallow them from coping it any further. I was thinking about some kind of program, that I could put on their pcs that would monitor the state of file.
Is there any method (or way) of programmaticaly checking it? if they attempt to copy it?
thanks.
_ra
|
|
|
|
|
short of shipping custom decoder/viewer there is not much you can do
|
|
|
|
|
No. You'll just have to tell them to not do it and trust that they won't.
Regards,
Alvaro
Quitters never win. Winners never quit. But those who never win and never quit are idiots. -- despair.com
|
|
|
|
|
Do you work for the MPAA or RIAA by any chance?
You can pick your friends, and you can pick your nose, but you can't pick your friend's nose.
|
|
|
|
|
no i don't work for any of those.
it's because someone at some office paid for some educational video or something (i'm not sure about details), and fears that if he gives it to his employees it will end up being copied all over the place and stuff liked that.
so, he asked if there was anything that could be done.
now, i was thinking about some shell extenstion perhaps, there is something that can intercept when you try to copy a file and then check for a file name and delete it.
_ra
|
|
|
|