For quick I / O, you usually want to read / write in a multiple of the block size of your file system / OS.
You can request the block size by calling statfseither fstatfsin your file or file descriptor (read the manual pages).
struct statfshas a field f_bsize, and sometimes f_iosize:
optimal transfer block size
f_bsize POSIX, AFAIK. Mac OS X iOS f_iosize, ( f_bsize Mac OS X/iOS , f_iosize, IIRC).
struct statfs fsInfo = {0};
int fd = fileno(fp);
long optimalSize;
if (fstatfs(fd, &fsInfo) == -1) {
optimalSize = 4 * 1024 * 1024;
} else {
optimalSize = fsInfo.f_bsize;
}
( read fread) . . EOF.
- , : mmap . , , , , , " " , ' ve, , .