@@ -1,106 +0,0 @@
1−{-# LANGUAGE ExistentialQuantification #-}
2−
3−import BenchUtils
4−import qualified Data.Text.Utf8.Fusion as U8
5−import qualified Data.Text.Utf8.Internal as U8I
6−import qualified Data.Text.Utf32.Fusion as U32
7−import qualified Data.Text.Utf32.Internal as U32I
8−import qualified Data.Text.Fusion as S
9−import Data.Text.Fusion (bsStream,Encoding(..))
10−import qualified Data.Text as T
11−import qualified Data.ByteString as B
12−import Text.Printf
13−import System.Mem
14−
15−instance Forceable U32I.Text
16−instance Forceable U8I.Text
17−
18−data E a = forall b. E (a -> b) | EText (a -> S.Stream Char)
19−
20−main = do force (ascii_tests, smp_sip_tests)
21− ascii <- B.readFile "ascii.txt"
22− let ascii8 = U8.unstream (bsStream ascii ASCII)
23− let ascii16 = S.unstream (bsStream ascii ASCII)
24− let ascii32 = U32.unstream (bsStream ascii ASCII)
25− force (ascii8, ascii16, ascii32)
26− printf " # Utf8\t\tUtf16\tUtf32\n"
27− run 1 (ascii8, ascii16, ascii32) ascii_tests
28− performGC
29− bmp <- B.readFile "bmp.txt"
30− let bmp8 = U8.unstream (bsStream bmp Utf8)
31− let bmp16 = S.unstream (bsStream bmp Utf8)
32− let bmp32 = U32.unstream (bsStream bmp Utf8)
33− force (bmp8, bmp16, bmp32)
34− printf " # Utf8\t\tUtf16\tUtf32\n"
35− run 1 (bmp8, bmp16, bmp32) ascii_tests
36− performGC
37− smp_sip <- B.readFile "smp_sip.txt"
38− let smp_sip8 = U8.unstream (bsStream smp_sip Utf8)
39− let smp_sip16 = S.unstream (bsStream smp_sip Utf8)
40− let smp_sip32 = U32.unstream (bsStream smp_sip Utf8)
41− force (smp_sip8, smp_sip16, smp_sip32)
42− printf " # Utf8\t\tUtf16\tUtf32\n"
43− run 1 (smp_sip8, smp_sip16, smp_sip32) smp_sip_tests
44−
45−ascii_tests = [
46− ("cons" ,
47− [F $ app1 $ U8.unstream . S.cons '\88' . U8.stream,
48− F $ app2 $ S.unstream . S.cons '\88' . S.stream,
49− F $ app3 $ U32.unstream . S.cons '\88' . U32.stream]),
50− ("length",
51− [F $ app1 $ S.length . U8.stream,
52− F $ app2 $ S.length . S.stream,
53− F $ app3 $ S.length . U32.stream]),
54− ("map" ,
55− [F $ app1 $ U8.unstream . S.map succ . U8.stream,
56− F $ app2 $ S.unstream . S.map succ . S.stream,
57− F $ app3 $ U32.unstream . S.map succ . U32.stream]),
58− ("filter",
59− [F $ app1 $ U8.unstream . S.filter (/= '\101') . U8.stream,
60− F $ app2 $ S.unstream . S.filter (/= '\101') . S.stream,
61− F $ app3 $ U32.unstream . S.filter (/= '\101') . U32.stream]),
62− ("take",
63− [F $ app1 $ U8.unstream . S.take 1000000 . U8.stream,
64− F $ app2 $ S.unstream . S.take 1000000 . S.stream,
65− F $ app3 $ U32.unstream . S.take 1000000 . U32.stream]),
66− ("drop" ,
67− [F $ app1 $ U8.unstream . S.drop 1000000 . U8.stream,
68− F $ app2 $ S.unstream . S.drop 1000000 . S.stream,
69− F $ app3 $ U32.unstream . S.drop 1000000 . U32.stream]),
70− ("foldl'",
71− [F $ app1 $ S.foldl' (\a w -> a+1::Int) 0 . U8.stream,
72− F $ app2 $ S.foldl' (\a w -> a+1::Int) 0 . S.stream,
73− F $ app3 $ S.foldl' (\a w -> a+1::Int) 0 . U32.stream
74− ])
75− ]
76−
77−smp_sip_tests = [
78− ("cons" ,
79− [F $ app1 $ U8.unstream . S.cons '\88' . U8.stream,
80− F $ app2 $ S.unstream . S.cons '\88' . S.stream,
81− F $ app3 $ U32.unstream . S.cons '\88' . U32.stream]),
82− ("length",
83− [F $ app1 $ S.length . U8.stream,
84− F $ app2 $ S.length . S.stream,
85− F $ app3 $ S.length . U32.stream]),
86− ("map" ,
87− [F $ app1 $ U8.unstream . S.map succ . U8.stream,
88− F $ app2 $ S.unstream . S.map succ . S.stream,
89− F $ app3 $ U32.unstream . S.map succ . U32.stream]),
90− ("filter",
91− [F $ app1 $ U8.unstream . S.filter (/= '\101') . U8.stream,
92− F $ app2 $ S.unstream . S.filter (/= '\101') . S.stream,
93− F $ app3 $ U32.unstream . S.filter (/= '\101') . U32.stream]),
94− ("take",
95− [F $ app1 $ U8.unstream . S.take 1000000 . U8.stream,
96− F $ app2 $ S.unstream . S.take 1000000 . S.stream,
97− F $ app3 $ U32.unstream . S.take 1000000 . U32.stream]),
98− ("drop" ,
99− [F $ app1 $ U8.unstream . S.drop 1000000 . U8.stream,
100− F $ app2 $ S.unstream . S.drop 1000000 . S.stream,
101− F $ app3 $ U32.unstream . S.drop 1000000 . U32.stream]),
102− ("foldl'",
103− [F $ app1 $ S.foldl' (\a w -> a+1::Int) 0 . U8.stream,
104− F $ app2 $ S.foldl' (\a w -> a+1::Int) 0 . S.stream,
105− F $ app3 $ S.foldl' (\a w -> a+1::Int) 0 . U32.stream])
106− ]