@@ -41,9 +41,12 @@ module Bench.Main where
4141
4242import Prelude
4343
44+ import Bench.Json.Parsing as BenchParsing
45+ import Bench.Json.StringParser as BenchStringParser
46+ import Bench.Json.TestData (largeJson , mediumJson , smallJson )
4447import Data.Array (fold , replicate )
4548import Data.Either (either )
46- import Data.List (manyRec )
49+ import Data.List (many , manyRec )
4750import Data.List.Types (List )
4851import Data.String.Regex (Regex , regex )
4952import Data.String.Regex as Regex
@@ -56,9 +59,9 @@ import Performance.Minibench (benchWith)
5659import Text.Parsing.Parser (Parser , runParser )
5760import Text.Parsing.Parser.String (string )
5861import 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
6265
6366string23 :: String
6467string23 = " 23"
@@ -100,7 +103,7 @@ pattern23 = either (unsafePerformEffect <<< throw) identity
100103 }
101104
102105parseSkidoo :: Parser String (List String )
103- parseSkidoo = manyRec $ string " skidoo"
106+ parseSkidoo = many $ string " skidoo"
104107
105108patternSkidoo :: Regex
106109patternSkidoo = either (unsafePerformEffect <<< throw) identity
@@ -138,3 +141,27 @@ main = do
138141 log " Regex.match patternSkidoo"
139142 benchWith 200
140143 $ \_ -> 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