On Thu, 4 Dec 2008, John Lato wrote:

> I've recently been doing some tests of different sound file I/O
> packages in Haskell, and I would like to share the results.  My test
> script involves reading a 66MB Wave file, a stereo recording at 44,100
> / 16.  The entire file is processed to determine the peak sample
> value.  This is of particular instance to me because it involves
> scanning a large amount of data in its entirety, the file format is
> extremely common, and the process seems representative of the sort of
> operations often encountered doing audio work.

Thank you for this benchmark! I'm particularly interested in 
StorableVector because I hacked it quite a bit and use it for my own 
signal processing.

I would also like to know how Fusion+Inlining improves the picture, but I 
do not know if there is anything to fuse at all in this simple example. 
Can you show us the actual test you run? I would then compare with my 
fusing signal data type from the synthesizer package.


> Test harnesses:
> HSoundFile-3 - a stream type is created to hold AudioBuffers.  A
> recursive reader function uses unsafeInterleaveIO to read the entire
> file on demand.  A strict foldl processes the Stream chunks to achieve
> the final value.
> Enumerator - An Iteratee is processes all values as received
> Codecs - the data list is processed by a strict foldl
> WAVE - the data list is processed by a strict foldl
> hsndfile - a recursive I/O function reads a chunk from the file (using
> IOCArray type) and accumulates the maximum values from each chunk.  I
> attempted to create a framework like used for HSoundFile-3, however
> performance dropped dramatically; I suspect the slowdown is mostly
> from the process of freezing mutable arrays to immutable arrays.
>
> API type:
> HSoundFile-3 - strict reads/writes of buffers
> Enumerator - enumerator-based strict I/O
> Codecs - read/write entire file into data structure
> WAVE - lazily read file into list
> hsndfile - strict reads/writes of buffers
>
> Data Types:
> HSoundFile-3 -  custom AudioBuffer class.  Implementations are
> provided for UArr Double, List Double, and StorableVector Double

StorableVector or StorableVector.Lazy? The latter seems appropriate here.

> Enumerator - enumerates Doubles
> Codecs - array of Doubles
> WAVE - [[Int32]]
> hsndfile - custom Buffer class with Array constraint.  Implementations
> are provided for IOCArray and StorableVector.
>
> For chunked data types, all data is with chunk size 1000.
> All timing/memory data is the median value from multiple runs.  In
> general different runs had very similar performance.
>
> Timing results:
> HSoundFile-3, StorableVector - real 16.5s
> HSoundFile-3, UArr                    - real 15.7s
> HSoundFile-3, List                      - real 17.6s

Is this the plain Prelude [] type? Why are List and StorableVector similar 
in speed?

> Codecs                                         - real 1m20s
> Enumerator                                  - real 19s
> WAVE                                            - real 29.1s
> hsndfile                                         - real 2.0s

You said, hsndfile can run with IOCArray and StorableVector. Which one did 
you use here?


> Anyway, that's what I've found so far.  I was very hopeful that at
> least one of  the pure haskell packages would be similar to hsndfile,
> but unfortunately I haven't found anything at this time.  It's
> certainly beyond my ability.

I'm also still not satisfied with the signal processing speed I achieve 
currently, although it increased dramatically using StorableVector instead 
of [Double]. Your simple task is certainly a good testcase to track down 
the problems.
_______________________________________________
haskell-art mailing list
haskell-art@lurk.org
http://lists.lurk.org/mailman/listinfo/haskell-art

Reply via email to