Difference between revisions of "Performance/Strings"

From HaskellWiki
Jump to navigation Jump to search
(Adding performance infobox for more nav options)
(→‎Strings: Formatting fixes)
Line 5: Line 5:
 
too much. In this case, you can instead use packed strings. There are a
 
too much. In this case, you can instead use packed strings. There are a
 
number of options:
 
number of options:
  +
* The standard Data.PackedString type
+
* The standard Data.PackedString type
* One of the newer packed string libraries, for example [http://www.cse.unsw.edu.au/~dons/fps.html FastPackedString]
+
* One of the newer packed string libraries, for example [http://www.cse.unsw.edu.au/~dons/fps.html FastPackedString]
* Unboxed arrays of Word8 or Char
 
* Ptrs to foreign malloced Word8 buffers
+
* Unboxed arrays of Word8 or Char
  +
* Ptrs to foreign malloced Word8 buffers
   
 
The packed string libraries have the benefit over arrays of Word8 or
 
The packed string libraries have the benefit over arrays of Word8 or

Revision as of 19:37, 17 February 2006

Haskell Performance Resource

Constructs:
Data Types - Functions
Overloading - FFI - Arrays
Strings - Integers - I/O
Floating point - Concurrency
Modules - Monads

Techniques:
Strictness - Laziness
Avoiding space leaks
Accumulating parameter

Implementation-Specific:
GHC - nhc98 - Hugs
Yhc - JHC

Strings

Sometimes the cost of representing strings as lists of Char can be too much. In this case, you can instead use packed strings. There are a number of options:

  • The standard Data.PackedString type
  • One of the newer packed string libraries, for example FastPackedString
  • Unboxed arrays of Word8 or Char
  • Ptrs to foreign malloced Word8 buffers

The packed string libraries have the benefit over arrays of Word8 or Char types, in that the provide the usual list-like operations.