@@ -5,7 +5,7 @@ module Main
5
5
( main
6
6
) where
7
7
8
- import Criterion.Main (Benchmark , defaultMain , bgroup )
8
+ import Criterion.Main (defaultMain , bgroup , env )
9
9
import System.FilePath ((</>) )
10
10
import System.IO (IOMode (WriteMode ), openFile , hSetEncoding , utf8 )
11
11
@@ -32,50 +32,42 @@ import qualified Benchmarks.Programs.StripTags as Programs.StripTags
32
32
import qualified Benchmarks.Programs.Throughput as Programs.Throughput
33
33
34
34
main :: IO ()
35
- main = benchmarks >>= defaultMain
36
-
37
- benchmarks :: IO [Benchmark ]
38
- benchmarks = do
35
+ main = do
39
36
sink <- openFile " /dev/null" WriteMode
40
37
hSetEncoding sink utf8
41
-
42
- -- Traditional benchmarks
43
- bs <- sequence
38
+ defaultMain
44
39
[ Builder. benchmark
45
40
, Concat. benchmark
46
- , DecodeUtf8. benchmark " html " (tf " libya-chinese.html" )
47
- , DecodeUtf8. benchmark " xml" (tf " yiwiki. xml" )
48
- , DecodeUtf8. benchmark " ascii" (tf " ascii.txt " )
49
- , DecodeUtf8. benchmark " russian" (tf " russian.txt " )
50
- , DecodeUtf8. benchmark " japanese" (tf " japanese.txt " )
41
+ , env ( DecodeUtf8. initEnv (tf " libya-chinese.html " )) ( DecodeUtf8. benchmark " html" )
42
+ , env ( DecodeUtf8. initEnv (tf " yiwiki. xml" )) ( DecodeUtf8. benchmark " xml" )
43
+ , env ( DecodeUtf8. initEnv (tf " ascii.txt " )) ( DecodeUtf8. benchmark " ascii" )
44
+ , env ( DecodeUtf8. initEnv (tf " russian.txt " )) ( DecodeUtf8. benchmark " russian" )
45
+ , env ( DecodeUtf8. initEnv (tf " japanese.txt " )) ( DecodeUtf8. benchmark " japanese" )
51
46
, EncodeUtf8. benchmark " επανάληψη 竺法蘭共譯"
52
- , Equality. benchmark (tf " japanese.txt" )
47
+ , env ( Equality. initEnv (tf " japanese.txt" )) Equality. benchmark
53
48
, FileRead. benchmark (tf " russian.txt" )
54
49
, FoldLines. benchmark (tf " russian.txt" )
55
- , Mul. benchmark
56
- , Pure. benchmark " tiny" (tf " tiny.txt" )
57
- , Pure. benchmark " ascii" (tf " ascii-small.txt" )
58
- -- , Pure.benchmark "france" (tf "france.html")
59
- , Pure. benchmark " russian" (tf " russian-small.txt" )
60
- , Pure. benchmark " japanese" (tf " japanese.txt" )
61
- , ReadNumbers. benchmark (tf " numbers.txt" )
62
- , Replace. benchmark (tf " russian.txt" ) " принимая" " своем"
63
- , Search. benchmark (tf " russian.txt" ) " принимая"
64
- , Stream. benchmark (tf " russian.txt" )
65
- , WordFrequencies. benchmark (tf " russian.txt" )
50
+ , env Mul. initEnv Mul. benchmark
51
+ , env (Pure. initEnv (tf " tiny.txt" )) (Pure. benchmark " tiny" )
52
+ , env (Pure. initEnv (tf " ascii-small.txt" )) (Pure. benchmark " ascii-small" )
53
+ , env (Pure. initEnv (tf " ascii.txt" )) (Pure. benchmark " ascii" )
54
+ , env (Pure. initEnv (tf " english.txt" )) (Pure. benchmark " english" )
55
+ , env (Pure. initEnv (tf " russian-small.txt" )) (Pure. benchmark " russian" )
56
+ , env (Pure. initEnv (tf " japanese.txt" )) (Pure. benchmark " japanese" )
57
+ , env (ReadNumbers. initEnv (tf " numbers.txt" )) ReadNumbers. benchmark
58
+ , env (Replace. initEnv (tf " russian.txt" )) (Replace. benchmark " принимая" " своем" )
59
+ , env (Search. initEnv (tf " russian.txt" )) (Search. benchmark " принимая" )
60
+ , env (Stream. initEnv (tf " russian.txt" )) Stream. benchmark
61
+ , env (WordFrequencies. initEnv (tf " russian.txt" )) WordFrequencies. benchmark
62
+ , bgroup " Programs"
63
+ [ Programs.BigTable. benchmark sink
64
+ , Programs.Cut. benchmark (tf " russian.txt" ) sink 20 40
65
+ , Programs.Fold. benchmark (tf " russian.txt" ) sink
66
+ , Programs.Sort. benchmark (tf " russian.txt" ) sink
67
+ , Programs.StripTags. benchmark (tf " yiwiki.xml" ) sink
68
+ , Programs.Throughput. benchmark (tf " russian.txt" ) sink
69
+ ]
66
70
]
67
-
68
- -- Program-like benchmarks
69
- ps <- bgroup " Programs" `fmap` sequence
70
- [ Programs.BigTable. benchmark sink
71
- , Programs.Cut. benchmark (tf " russian.txt" ) sink 20 40
72
- , Programs.Fold. benchmark (tf " russian.txt" ) sink
73
- , Programs.Sort. benchmark (tf " russian.txt" ) sink
74
- , Programs.StripTags. benchmark (tf " yiwiki.xml" ) sink
75
- , Programs.Throughput. benchmark (tf " russian.txt" ) sink
76
- ]
77
-
78
- return $ bs ++ [ps]
79
- where
71
+ where
80
72
-- Location of a test file
81
73
tf = (" ../tests/text-test-data" </> )
0 commit comments