B
Buzz Lightyear
Hi, guys,
If I want to write a large block of data into disk file with maximum
speed, what's the best way to do it.
It looks to give a proper Block Size while writing is a key factor.
int writeFile(char* data, unsigned int size)
{
FILE * pFile;
pFile = fopen ( "myfile.bin" , "wb" );
unsigned int offset(0);
Assert( size > BLOCK_SIZE);
char* targetData( data );
while( offset < size )
{
fwrite (targetData, BLOCK_SIZE , sizeof(char) , pFile );
offset += BLOCK_SIZE;
targetData += BLOCK_SIZE;
}
if( offset < size )
fwrite (targetData, size - offset , sizeof(char) , pFile );
fclose (pFile);
return 0;
}
So how to define a proper BLOCK_SIZE, 1MB, 10MB, or 4KB.
Thanks!
If I want to write a large block of data into disk file with maximum
speed, what's the best way to do it.
It looks to give a proper Block Size while writing is a key factor.
int writeFile(char* data, unsigned int size)
{
FILE * pFile;
pFile = fopen ( "myfile.bin" , "wb" );
unsigned int offset(0);
Assert( size > BLOCK_SIZE);
char* targetData( data );
while( offset < size )
{
fwrite (targetData, BLOCK_SIZE , sizeof(char) , pFile );
offset += BLOCK_SIZE;
targetData += BLOCK_SIZE;
}
if( offset < size )
fwrite (targetData, size - offset , sizeof(char) , pFile );
fclose (pFile);
return 0;
}
So how to define a proper BLOCK_SIZE, 1MB, 10MB, or 4KB.
Thanks!