Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Effective file I/O with bytestrings (Antoine Latter)
2. Re: Effective file I/O with bytestrings (Alexander V Vershilov)
----------------------------------------------------------------------
Message: 1
Date: Fri, 10 Feb 2012 06:36:19 -0600
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] Effective file I/O with bytestrings
To: Johannes Engels <[email protected]>
Cc: [email protected]
Message-ID:
<CAKjSnQHdpRMXkh=pte8d6uwmebhm30ifftb8nzjd7rafgyq...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
On Fri, Feb 10, 2012 at 3:31 AM, Johannes Engels
<[email protected]> wrote:
> Dear Haskellers,
>
> in several books (RWH, LYAH) I have found the statement that file I/O is
> more effective with bytestrings than with common strings. As I am doing
> mostly scientific programming and nearly every program of mine uses file
> I/O, I would like to check this. So I tried to write a small "benchmark":
> read a double matrix from file and write it to file again. Regarding to
> reading, the benefit of bytestrings was actually huge, it was about ten
> times faster than with strings. What refers to writing, however, I failed
> completely. Most important, I did not find a function which directly
> converts doubles to bytestrings. So the best I could figure out was the
> following ugly workaround using Text.Show.ByteString:
>
Using a ByteString as an accumulator can be not-great. A lot of folks
use some sort of specialized 'builder' type, like this one:
http://hackage.haskell.org/packages/archive/blaze-builder/0.3.1.0/doc/html/Blaze-ByteString-Builder.html
Antoine
------------------------------
Message: 2
Date: Fri, 10 Feb 2012 19:17:33 +0400
From: Alexander V Vershilov <[email protected]>
Subject: Re: [Haskell-beginners] Effective file I/O with bytestrings
To: Antoine Latter <[email protected]>
Cc: [email protected], Johannes Engels
<[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Fri, Feb 10, 2012 at 06:36:19AM -0600, Antoine Latter wrote
> On Fri, Feb 10, 2012 at 3:31 AM, Johannes Engels
> <[email protected]> wrote:
> > Dear Haskellers,
> >
> > in several books (RWH, LYAH) I have found the statement that file I/O is
> > more effective with bytestrings than with common strings. As I am doing
> > mostly scientific programming and nearly every program of mine uses file
> > I/O, I would like to check this. So I tried to write a small "benchmark":
> > read a double matrix from file and write it to file again. Regarding to
> > reading, the benefit of bytestrings was actually huge, it was about ten
> > times faster than with strings. What refers to writing, however, I failed
> > completely. Most important, I did not find a function which directly
> > converts doubles to bytestrings. So the best I could figure out was the
> > following ugly workaround using Text.Show.ByteString:
> >
>
> Using a ByteString as an accumulator can be not-great. A lot of folks
> use some sort of specialized 'builder' type, like this one:
>
> http://hackage.haskell.org/packages/archive/blaze-builder/0.3.1.0/doc/html/Blaze-ByteString-Builder.html
>
> Antoine
>
Also if for storing matrix in binary form some serialization packages can be
used:
Binary: http://hackage.haskell.org/package/binary-0.5.1.0
Cereal: http://hackage.haskell.org/package/cereal-0.3.5.1
http://hackage.haskell.org/package/cereal-ieee754
--
Alexander V Vershilov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120210/4f181d54/attachment-0001.pgp>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 44, Issue 11
*****************************************