File: ByteString.hs

package info (click to toggle)
haskell-unordered-containers 0.2.20-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 376 kB
  • sloc: haskell: 4,446; makefile: 6
file content (28 lines) | stat: -rw-r--r-- 1,091 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- | Benchmarking utilities.  For example, functions for generating
-- random 'ByteString's.
module Util.ByteString where

import qualified Data.ByteString       as S
import qualified Data.ByteString.Char8 as C
import qualified Util.String           as String

-- | Generate a number of fixed length 'ByteString's where the content
-- of the strings are letters in ascending order.
asc :: Int  -- ^ Length of each string
    -> Int  -- ^ Number of strings
    -> [S.ByteString]
asc strlen num = map C.pack $ String.asc strlen num

-- | Generate a number of fixed length 'ByteString's where the content
-- of the strings are letters in random order.
rnd :: Int  -- ^ Length of each string
    -> Int  -- ^ Number of strings
    -> [S.ByteString]
rnd strlen num = map C.pack $ String.rnd strlen num

-- | Generate a number of fixed length 'ByteString's where the content
-- of the strings are letters in random order, different from @rnd@.
rnd' :: Int  -- ^ Length of each string
     -> Int  -- ^ Number of strings
     -> [S.ByteString]
rnd' strlen num = map C.pack $ String.rnd' strlen num