fastest i/o ? - Programmer

This is a discussion on fastest i/o ? - Programmer ; which is faster: _read (low-level, unbuffered) or fread (stream, buffered) ? generally, which input functions are faster ? what about the sector size buffer penalty associated with _read ? thanks...

+ Reply to Thread
Results 1 to 4 of 4

Thread: fastest i/o ?

  1. fastest i/o ?

    which is faster:
    _read (low-level, unbuffered) or
    fread (stream, buffered) ?

    generally, which input functions are faster ?

    what about the sector size buffer penalty associated with _read ?

    thanks



  2. Re: fastest i/o ?

    "flekso" wrote in message
    news:bej32d$bb9l$1@as201.hinet.hr...
    > which is faster:
    > _read (low-level, unbuffered) or
    > fread (stream, buffered) ?
    >
    > generally, which input functions are faster ?


    Usually neither. _read is a thin wrapper around ReadFile, and fread adds
    buffering to _read. fread will be faster if you only ever read a few bytes
    at a time, because ReadFile (and therefore _read) has a fixed overhead
    arising from the switch to kernel mode and back. However, this is only of
    the order of hundreds of clock cycles.

    > what about the sector size buffer penalty associated with _read ?


    What sector size buffer penalty?

    --
    Tim Robinson (MVP, Windows SDK)
    http://www.themobius.co.uk/



  3. Re: fastest i/o ?

    "Tim Robinson" wrote in message
    news:bej750$5qbqh$1@ID-103400.news.dfncis.de...
    > "flekso" wrote in message
    > news:bej32d$bb9l$1@as201.hinet.hr...
    > > which is faster:
    > > _read (low-level, unbuffered) or
    > > fread (stream, buffered) ?
    > >
    > > generally, which input functions are faster ?

    >
    > Usually neither. _read is a thin wrapper around ReadFile, and fread adds
    > buffering to _read. fread will be faster if you only ever read a few bytes
    > at a time, because ReadFile (and therefore _read) has a fixed overhead
    > arising from the switch to kernel mode and back. However, this is only of
    > the order of hundreds of clock cycles.


    so the best solution is to stick with the api? -will it work from console
    app?


    > > what about the sector size buffer penalty associated with _read ?

    >
    > What sector size buffer penalty?


    i've read somewhere on google groups that _read's buffer size must be a
    multiple of sector size otherwise there will be a penalty.



  4. Re: fastest i/o ?

    "flekso" wrote in message
    news:bejd82$cmvk$1@as201.hinet.hr...
    > so the best solution is to stick with the api? -will it work from

    console
    > app?


    Do whatever you want. Using something other than fread will stop your
    program from being portable to other systems, but then again, so will any
    other Windows function.

    I see no reason to use _read instead of ReadFile, unless you want to keep
    compatibility with some Posix code base.

    > i've read somewhere on google groups that _read's buffer size must be a
    > multiple of sector size otherwise there will be a penalty.


    I've never heard of that.

    --
    Tim Robinson (MVP, Windows SDK)
    http://www.themobius.co.uk/



+ Reply to Thread