Hi BSD guys,

While I was doing simple file read test, I found that there is a huge
difference in file read performance between read() and fread(). I'm
wondering if I'm doing something wrong or if someone has experienced
similar things.

Here is what I did,

For the specific application, I need to bypass cache (I read only
once, and that's all)
The test file is 700Mbytes dummy file.
Test app just reads the whole file.

Test is done on FreeBSD 7.1 amd 64, Celeron E1200, WD Caviar SE16 SATA 7200 RPM

For test 1,

fd = open(name, O_RDONLY | O_DIRECT);
while(...) {
  cnt = read(....);
  ....
}

for test 2,

fd = open(name, O_RDONLY | O_DIRECT);
file = fdopen(fd,"r");
while(...) {
  cnt = fread(....);
  ....
}

test 1 takes about 11.64 seconds (63 MBytes/s), and test 2 takes about
51.53 seconds (14 MBytes/s)

If I use the pair of fopen() and fread(), it will have cache effect,
so the result doesn't say much of hdd performance.

Personally, I don't think the overhead of fread() (wrapper in libc) is
that huge. What would be the reason for this?

Thanks.

--
Junsuk
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to