Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 50 lines (36 sloc) 1.553 kb
0bd90711 »
2011-03-24 Implement decompression of lazy bytestrings.
1 {-# LANGUAGE FlexibleInstances #-}
f9f556e0 »
2011-03-26 Benchmark compression functions over pure and impure inputs
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
0bd90711 »
2011-03-24 Implement decompression of lazy bytestrings.
3
f9f556e0 »
2011-03-26 Benchmark compression functions over pure and impure inputs
4 import Control.Applicative ((<$>), (<*>))
5 import Functions (rechunk)
6 import Test.Framework (defaultMain)
ca7e79ec »
2011-03-23 Initial commit
7 import Test.Framework.Providers.QuickCheck2 (testProperty)
8 import Test.QuickCheck (Arbitrary(..))
f9f556e0 »
2011-03-26 Benchmark compression functions over pure and impure inputs
9 import qualified Codec.Compression.Snappy as B
10 import qualified Codec.Compression.Snappy.Lazy as L
ca7e79ec »
2011-03-23 Initial commit
11 import qualified Data.ByteString as B
372539fe »
2011-03-23 Add support for compression of lazy bytestrings.
12 import qualified Data.ByteString.Lazy as L
ca7e79ec »
2011-03-23 Initial commit
13
0bd90711 »
2011-03-24 Implement decompression of lazy bytestrings.
14 instance Arbitrary B.ByteString where
15 arbitrary = B.pack <$> arbitrary
16
17 instance Arbitrary L.ByteString where
f9f556e0 »
2011-03-26 Benchmark compression functions over pure and impure inputs
18 arbitrary = smallChunk <$> arbitrary <*> arbitrary
0bd90711 »
2011-03-24 Implement decompression of lazy bytestrings.
19
20 s_roundtrip bs = B.decompress (B.compress bs) == bs
21
22 newtype Compressed a = Compressed { compressed :: a }
23 deriving (Eq, Ord)
24
25 instance Show a => Show (Compressed a)
26 where show (Compressed a) = "Compressed " ++ show a
27
28 instance Arbitrary (Compressed B.ByteString) where
29 arbitrary = (Compressed . B.compress) <$> arbitrary
30
f9f556e0 »
2011-03-26 Benchmark compression functions over pure and impure inputs
31 compress_eq n bs = L.fromChunks [B.compress bs] == L.compress (smallChunk n bs)
c8298d30 »
2011-03-26 Rename the snappy benchmark to speedy
32 decompress_eq n (Compressed bs) =
f9f556e0 »
2011-03-26 Benchmark compression functions over pure and impure inputs
33 L.fromChunks [B.decompress bs] == L.decompress (smallChunk n bs)
0bd90711 »
2011-03-24 Implement decompression of lazy bytestrings.
34
f9f556e0 »
2011-03-26 Benchmark compression functions over pure and impure inputs
35 t_rechunk n bs = L.fromChunks [bs] == smallChunk n bs
ca7e79ec »
2011-03-23 Initial commit
36
0bd90711 »
2011-03-24 Implement decompression of lazy bytestrings.
37 l_roundtrip bs = L.decompress (L.compress bs) == bs
372539fe »
2011-03-23 Add support for compression of lazy bytestrings.
38
f9f556e0 »
2011-03-26 Benchmark compression functions over pure and impure inputs
39 smallChunk n = rechunk ((n `mod` 63) + 1)
40
ca7e79ec »
2011-03-23 Initial commit
41 main = defaultMain tests
42
43 tests = [
372539fe »
2011-03-23 Add support for compression of lazy bytestrings.
44 testProperty "s_roundtrip" s_roundtrip
0bd90711 »
2011-03-24 Implement decompression of lazy bytestrings.
45 , testProperty "t_rechunk" t_rechunk
46 , testProperty "compress_eq" compress_eq
47 , testProperty "decompress_eq" decompress_eq
372539fe »
2011-03-23 Add support for compression of lazy bytestrings.
48 , testProperty "l_roundtrip" l_roundtrip
ca7e79ec »
2011-03-23 Initial commit
49 ]
Something went wrong with that request. Please try again.