should you use fread/fwrite or read/write system calls when you want to specify the buffer size explicitly?

jsguy

I have an application where I want to read/write data from/to a hard drive, but at the same time I want to specify the size of the buffer that is going to be used in order to make the application more efficient (I/O related).

I implemented two versions, one using read/write system calls and one using fread/fwrite functions where to specify the buffer size I made a call to the setvbuf function.

I noticed however a difference in the running times for large inputs in the order of 2.

This raised some questions as to whether using read/write system calls should always be preferred when you want to exploit the ability of transfering blocks of data from the disk in order to minimize the total amount of I/Os.

kennyzx

It depends on how much data to read/write, if you set the buffer to be very tiny, it is inefficient to read/write large amount of data.

Here is a comparison.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

should you use fread/fwrite or read/write system calls when you want to specify the buffer size explicitly?

From Dev

When should you explicitly use a StringBuilder?

From Dev

gwan dynamic buffer, how often to use and when should you not use it?

From Dev

gwan dynamic buffer, how often to use and when should you not use it?

From Dev

What type should you use when you want to use index.advanceBy?

From Java

When should you NOT use React memo?

From Dev

When should you not use [[carries_dependency]]?

From Dev

When should you use Firebase Transactions

From Dev

When should you use subshells vs `xargs`?

From Dev

When should you use $limit in mongo?

From Dev

When should you use ParseForm and when should you use FormValue and PostFormValue?

From Dev

Why do you have to specify 2 arguments explicitly to curry :>

From Dev

Should you use named functions when developing a JavaScript library?

From Java

What is {this.props.children} and when you should use it?

From Java

Should you ever use this.setState() when using redux?

From Java

When should you use a class vs a struct in C++?

From Java

When should you use render and shallow in Enzyme / React tests?

From Java

When should you use CrtAllocator vs MemoryPoolAllocator in RapidJSON?

From Dev

when should you use __bridge vs. CFBridgingRelease/CFBridgingRetain?

From Dev

Should you always use with when printing to files in python

From Dev

When should you use different numeric types in Postgres?

From Dev

When should you not use allow-cross-orgin?

From Dev

Should you use IIFE with RequireJS

From Dev

Why should you not use setXXXSize()?

From Dev

When should you await a Task?

From Dev

When you should implement Runnable?

From Java

When should I use @synthesize explicitly?

From Dev

Should you always use the jQuery first() method when you know there will only be one matching element?

From Dev

When I exit a screen, I should be asked: “Do you want to save?” codeigniter

Related Related

  1. 1

    should you use fread/fwrite or read/write system calls when you want to specify the buffer size explicitly?

  2. 2

    When should you explicitly use a StringBuilder?

  3. 3

    gwan dynamic buffer, how often to use and when should you not use it?

  4. 4

    gwan dynamic buffer, how often to use and when should you not use it?

  5. 5

    What type should you use when you want to use index.advanceBy?

  6. 6

    When should you NOT use React memo?

  7. 7

    When should you not use [[carries_dependency]]?

  8. 8

    When should you use Firebase Transactions

  9. 9

    When should you use subshells vs `xargs`?

  10. 10

    When should you use $limit in mongo?

  11. 11

    When should you use ParseForm and when should you use FormValue and PostFormValue?

  12. 12

    Why do you have to specify 2 arguments explicitly to curry :>

  13. 13

    Should you use named functions when developing a JavaScript library?

  14. 14

    What is {this.props.children} and when you should use it?

  15. 15

    Should you ever use this.setState() when using redux?

  16. 16

    When should you use a class vs a struct in C++?

  17. 17

    When should you use render and shallow in Enzyme / React tests?

  18. 18

    When should you use CrtAllocator vs MemoryPoolAllocator in RapidJSON?

  19. 19

    when should you use __bridge vs. CFBridgingRelease/CFBridgingRetain?

  20. 20

    Should you always use with when printing to files in python

  21. 21

    When should you use different numeric types in Postgres?

  22. 22

    When should you not use allow-cross-orgin?

  23. 23

    Should you use IIFE with RequireJS

  24. 24

    Why should you not use setXXXSize()?

  25. 25

    When should you await a Task?

  26. 26

    When you should implement Runnable?

  27. 27

    When should I use @synthesize explicitly?

  28. 28

    Should you always use the jQuery first() method when you know there will only be one matching element?

  29. 29

    When I exit a screen, I should be asked: “Do you want to save?” codeigniter

HotTag

Archive