Read Speed Test

The following terminal output shows the difference in processing requirements for 24bit little endian and 32bit float wav files when loading from the disk. This is a strong indicator that we should ALWAYS keep our wav files in 32bit on disk to enhance disk streaming.

  time ./test.out test_24le.wav
  real	0m13.421s
  user	0m9.944s
  sys	0m3.464s

  time ./test.out test_float.wav
  real	0m4.410s
  user	0m0.376s
  sys	0m4.028s

The code:

#include <sndfile.h>
 
#define N 100
 
int main(int argc, char*argv[])
{ 
        for(int n = 0; n < N; ++n)
        {
                SF_INFO sf_info;
                SNDFILE *fh = sf_open(argv[1], SFM_READ, &sf_info);
                float samples[1024];
                while(1)
                {
                        sf_count_t r = sf_read_float(fh, samples, 1024);
                        if(r < 1024) break;
                }
                sf_close(fh);
        }
        return 1;
}

The files used were ~200MB