c# - Should I always minimize IO in my App -


i have c# desktop app.

it 'reads' 4 digital cameras 1 jpeg frame @ time.

each jpeg no more 20k bytes. every motion movement detected save frame hard drive.

the other way store footage create avi files in managed code , split after size has built up.

the reason save 1 jpeg @ time if burglar steals pc app running or/and pc reboots or/and app stops able save latest frame.

if took avi approach lose whatever cut-off had set in code.

i know if burglar stole pc have footage circumvent saving external hard drive stored in safe (for example).

so, bearing in mind low number of bytes save (but possibly frequent) best can hope achieve in terms of memory efficiency?

thanks

let's consider different aspects of problem.

writing rate

your maximum writing rate 800kb/s (10 fps, 4 camera, 20kb each frame) not high on modern hdd (even external hard drive). less of importance if using ssd.

how improve writing efficiency

traditionally, writing efficiency improved caching data buffer , writing big chuncks of data when buffer reach size. in case, think bad idea write own buffer mechanism.

  1. most operating system have kind of caching mechanism prevent disk thrashing , fragmentation of data.
  2. you want have latest frame possible written disk, i.e. prevent loss of data. caching contrary since delay writing , whole buffer lost in case of failure (e.g. in case if unplug device).

that's why think should keep implementation simplest possible (think kiss). might consider disabling operating system caching. might cause more fragmentation of data ensure have recent frame written on disk. (note in case of ssd, fragmentation issue irrelevant.)


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -