Change BlockMatch to use memcmp, that might help a bit.
"Greg Ercolano" <erco@3dsite.com> wrote in message
news:q60Sf.51$eK.46@fe04.lga...
Peter Olcott wrote:
I wrote a program that verifies the results of the XCOPY command.
xcopy has a verify flag, 'xcopy /v ..'
Is it any faster than your program?
It would also
verify the results of the cut-and-paste operation done in Windows
Explorer. The problem is that this program seems slower that it should
be.
Might be due to the buffer size you're using to read the file.
try making a loop that tests with different values, starting with
1024, 2048, 4096, 8192.. up to maybe 32k. Time each, and see which
is the fastest.
Posting some code might also give us an idea of what you're doing..
just the part that does the file open and read/verify loop.
int BlockMatch(int NUMbytes)
{
int N;
for (N = 0 ; N < NUMbytes ; N++)
if (BLOCK1[N] != BLOCK2[N])
return N;
return 0;
}
bool Check4MATCH(int FD1, int FD2, std::string& FullPathSource)
{
int NUM1read, NUM2read;
NUM1read = _read(FD1, BLOCK1, BLOCKSIZE);
NUM2read = _read(FD2, BLOCK2, BLOCKSIZE);
while (NUM1read && NUM2read) {
if (NUM1read != NUM2read) {
printf("ERROR, Block Read <%s> (%d <> %d) BYTES\n",
FullPathSource.c_str(), NUM1read, NUM2read);
return false;
}
int ByteNumberOfMisMatch = BlockMatch(NUM1read);
if (ByteNumberOfMisMatch) {
printf("ERROR, Block Read <%s> ByteNumber(%d)\n",
FullPathSource.c_str(), ByteNumberOfMisMatch);
return false;
}
NUM1read = _read(FD1, BLOCK1, BLOCKSIZE);
NUM2read = _read(FD2, BLOCK2, BLOCKSIZE);
}
return true;
}
a subdirectory of a network drive to an ISO image, and this takes six
minutes. I burn this to a DVD disk, and it takes another six minutes. In
other words copying all of the data once takes only six minutes. When I
run my command line program that compares all of the files copied to the
DVD copy it takes twenty-one minutes.
Oh, you're comparing to the DVD.
So basically you're reading data both from the HD drive and DVD drive.
Are you doing this serially with blocking reads, or are you doing it
async style, so that you can schedule two reads at once, then wait for
both
to complete, which may be quite a bit faster.
Why does the command line program take so much longer, and what windows
functions can I use to make it much faster? Can I use windows functions
in a command line program?
Yes, you can use WIN32 calls like CreateFile() / ReadFile().
Look into async reads; follow the docs on CreateFile/ReadFile,
and MSDN articles on async I/O.
But make sure you're using good buffer sizes first.
That sounds like good advice if I convert them to async that could double
my performance. Trying different block sizes sounds like a good idea too.
Can you see anything that can be improved in the code that I posted?