From b6a8060c9b9744b421b012802b62d3250536ad9f Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Fri, 14 Jun 2019 20:11:19 -0400 Subject: crayne parser: add full-parse benchmark. --- test/bench.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/bench.hs b/test/bench.hs index 3c4cf1e..a8ba239 100644 --- a/test/bench.hs +++ b/test/bench.hs @@ -23,6 +23,8 @@ import qualified Graphics.WaveFront.Parse as Parse import qualified Graphics.WaveFront.Parse.Common as Parse import Wavefront.Lex +import qualified Data.Wavefront as C +import Wavefront as C import Criterion.Main #ifdef WEIGH @@ -39,7 +41,7 @@ cube_obj = L.fromChunks . pure . unsafePerformIO $ do {-# NOINLINE cube_obj #-} cube_objT :: Text -cube_objT = decodeASCII $ L.toStrict cube_obj +cube_objT = decodeUtf8 $ L.toStrict cube_obj {-# NOINLINE cube_objT #-} countVerticesSabadie :: Text -> Int @@ -63,6 +65,13 @@ countVerticesCrayne bs = execState (parseOBJ builder (ObjConfig IntMap.empty) bs { vertex = \_ -> modify succ } +countVerticesCrayneFull :: L.ByteString -> Int +countVerticesCrayneFull ts = V.length vs + where + obj = C.parse ts + vs = C.objLocations obj + + sabadie :: Text -> Either String WavefrontOBJ sabadie = fmap (ctxtToWavefrontOBJ . lexer) . tokenize @@ -78,6 +87,7 @@ main = do defaultMain [ bgroup "count vertices" [ bench "crayne" $ whnf countVerticesCrayne cube_obj + , bench "crayneFull" $ whnf countVerticesCrayneFull cube_obj , bench "sabadie" $ whnf countVerticesSabadie cube_objT , bench "sundqvist" $ whnf countVerticesSundqvist cube_objT ] @@ -85,6 +95,7 @@ main = do #ifdef WEIGH Weigh.mainWith $ do func "crayne" countVerticesCrayne cube_obj + func "crayneFull" countVerticesCrayneFull cube_obj func "sabadie" countVerticesSabadie cube_objT func "sundqvist" countVerticesSundqvist cube_objT #endif -- cgit v1.2.3