[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[TSVN] File writing performance

From: Will Dean <svn_at_indcomp.co.uk>
Date: 2005-06-30 12:04:04 CEST

Hi all,

There was a little bit of discussion the other day about file writing
performance.

Because this came up again in something I was doing for work, I've just
tried the following:

Timing this:

         FILE* pOutFile = fopen("csfile", "wb");
         long val = 0x12345678;
         for(int i = 0; i < 1000000; i++)
         {
                 fwrite(&val, sizeof(val), 1, pOutFile);
         }
         fclose(pOutFile);

against this:

         HANDLE outFile = CreateFile("w32file", GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
         long val = 0x12345678;
         DWORD writeLength;
         for(int i = 0; i < 1000000; i++)
         {
                 WriteFile(outFile, &val, sizeof(val), &writeLength, NULL);
         }
         CloseHandle(outFile);

Both these write an identical 4000000 byte file.
On my machine here, you get results which look like this:

C Stream time: 41ms
W32 time: 3810ms

I would be interested if other people found these typical - I have attached
the source code of the entire app if people want to play with it.

Or is there something suspect in my methodology?

Cheers,

Will

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org

Received on Thu Jun 30 12:30:49 2005

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.