fread
already buffers data, i.e. internally reads it in chunks typically 4K or 8K in size (the exact default buffer size is defined by the implementation). For this reason, switching your reads from 1K to 4K does nothing, as it only decreases the number of memcpy
operations, which are cheap enough not to register in the benchmark above statistical noise.
To influence the size of the stdio
buffer, take a look at setbuf
.
Also, what you are changing is not line size because you're not reading the file line by line, but chunk size.