@@ -41,9 +41,12 @@ module Bench.Main where
41
41
42
42
import Prelude
43
43
44
+ import Bench.Json.Parsing as BenchParsing
45
+ import Bench.Json.StringParser as BenchStringParser
46
+ import Bench.Json.TestData (largeJson , mediumJson , smallJson )
44
47
import Data.Array (fold , replicate )
45
48
import Data.Either (either )
46
- import Data.List (manyRec )
49
+ import Data.List (many , manyRec )
47
50
import Data.List.Types (List )
48
51
import Data.String.Regex (Regex , regex )
49
52
import Data.String.Regex as Regex
@@ -56,9 +59,9 @@ import Performance.Minibench (benchWith)
56
59
import Text.Parsing.Parser (Parser , runParser )
57
60
import Text.Parsing.Parser.String (string )
58
61
import Text.Parsing.Parser.String.Basic (digit )
59
- import Text.Parsing. StringParser as StringParser
60
- import Text.Parsing. StringParser.CodePoints as StringParser.CodePoints
61
- import Text.Parsing. StringParser.CodeUnits as StringParser.CodeUnits
62
+ import StringParser as StringParser
63
+ import StringParser.CodePoints as StringParser.CodePoints
64
+ import StringParser.CodeUnits as StringParser.CodeUnits
62
65
63
66
string23 :: String
64
67
string23 = " 23"
@@ -100,7 +103,7 @@ pattern23 = either (unsafePerformEffect <<< throw) identity
100
103
}
101
104
102
105
parseSkidoo :: Parser String (List String )
103
- parseSkidoo = manyRec $ string " skidoo"
106
+ parseSkidoo = many $ string " skidoo"
104
107
105
108
patternSkidoo :: Regex
106
109
patternSkidoo = either (unsafePerformEffect <<< throw) identity
@@ -138,3 +141,27 @@ main = do
138
141
log " Regex.match patternSkidoo"
139
142
benchWith 200
140
143
$ \_ -> Regex .match patternSkidoo stringSkidoo_10000
144
+
145
+ log " runParser json smallJson"
146
+ benchWith 1000
147
+ $ \_ -> runParser smallJson BenchParsing .json
148
+
149
+ log " StringParser.runParser json smallJson"
150
+ benchWith 1000
151
+ $ \_ -> StringParser .runParser BenchStringParser .json smallJson
152
+
153
+ log " runParser json mediumJson"
154
+ benchWith 500
155
+ $ \_ -> runParser mediumJson BenchParsing .json
156
+
157
+ log " StringParser.runParser json mediumJson"
158
+ benchWith 500
159
+ $ \_ -> StringParser .runParser BenchStringParser .json mediumJson
160
+
161
+ log " runParser json largeJson"
162
+ benchWith 100
163
+ $ \_ -> runParser largeJson BenchParsing .json
164
+
165
+ log " StringParser.runParser json largeJson"
166
+ benchWith 100
167
+ $ \_ -> StringParser .runParser BenchStringParser .json largeJson
0 commit comments