From 8e3871e17250102ac3dfc3b65393e444d57058bb Mon Sep 17 00:00:00 2001 From: Adithya Kumar Date: Thu, 27 Jan 2022 17:17:16 +0530 Subject: [PATCH 1/2] Replace functionality of split with streamly --- bench-show.cabal | 7 +++---- lib/BenchShow/Common.hs | 11 +++++++++-- test/Doc.hs | 12 ++++++++++-- test/Main.hs | 15 ++++++++++++--- 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/bench-show.cabal b/bench-show.cabal index 0aa7b27..6a2d5f4 100644 --- a/bench-show.cabal +++ b/bench-show.cabal @@ -119,7 +119,7 @@ library , directory >= 1.2 && < 1.4 , transformers >= 0.4 && < 0.7 , ansi-wl-pprint >= 0.6 && < 0.7 - , split >= 0.2 && < 0.3 + , streamly >= 0.8 && < 0.9 , statistics >= 0.15 && < 0.17 , vector >= 0.10 && < 0.13 @@ -139,7 +139,6 @@ executable bench-show , directory >= 1.2 && < 1.4 , transformers >= 0.4 && < 0.7 , ansi-wl-pprint >= 0.6 && < 0.7 - , split >= 0.2 && < 0.3 , statistics >= 0.15 && < 0.17 , vector >= 0.10 && < 0.13 , semigroups >= 0.18 && < 0.21 @@ -160,7 +159,7 @@ test-suite test build-depends: bench-show , base >= 4.8 && < 4.17 - , split >= 0.2 && < 0.3 + , streamly >= 0.8 && < 0.9 , text >= 1.1.1 && < 2.1 -- , typed-process >= 0.1.0.0 && < 0.3 @@ -177,4 +176,4 @@ test-suite doc build-depends: bench-show , base >= 4.8 && < 4.17 - , split >= 0.2 && < 0.3 + , streamly >= 0.8 && < 0.9 diff --git a/lib/BenchShow/Common.hs b/lib/BenchShow/Common.hs index e789f73..7994e77 100644 --- a/lib/BenchShow/Common.hs +++ b/lib/BenchShow/Common.hs @@ -47,10 +47,10 @@ import Control.Monad (when, unless) import Data.Char (toLower) import Data.Foldable (foldl') import Data.Function ((&), on) +import Data.Functor.Identity (runIdentity) import Data.List (transpose, groupBy, (\\), find, sortBy, elemIndex, intersect, intersectBy) -import Data.List.Split (linesBy) import Data.Maybe (fromMaybe, mapMaybe) import Data.Ord (comparing) import Debug.Trace (trace) @@ -60,6 +60,9 @@ import System.FilePath (()) import Text.CSV (CSV, parseCSVFromFile) import Text.Read (readMaybe) +import qualified Streamly.Prelude as Stream +import qualified Streamly.Data.Fold as Fold + import BenchShow.Analysis ------------------------------------------------------------------------------- @@ -854,7 +857,11 @@ filterFields fieldNames BenchmarkIterMatrix{..} = splitRuns :: NumberedLines -> ([String], [NumberedLines]) splitRuns csvlines = let header = snd $ head csvlines - ls = linesBy (\x -> snd x == header) (tail csvlines) + ls = + runIdentity + $ Stream.toList + $ Stream.splitOnSuffix (\x -> snd x == header) Fold.toList + $ Stream.fromList (tail csvlines) in (header, ls) readWithError :: Read a => Int -> String -> (String, String) -> a diff --git a/test/Doc.hs b/test/Doc.hs index a071fbe..25f0ce3 100644 --- a/test/Doc.hs +++ b/test/Doc.hs @@ -4,14 +4,22 @@ module Main where import Data.Ord (comparing) import Data.List (sortBy) -import Data.List.Split (splitOn) +import Data.Functor.Identity (runIdentity) + +import qualified Streamly.Prelude as Stream +import qualified Streamly.Data.Fold as Fold import BenchShow +splitOn :: Eq a => a -> [a] -> [[a]] +splitOn d = + runIdentity + . Stream.toList . Stream.splitOn (== d) Fold.toList . Stream.fromList + main :: IO () main = do let classifier name = - case splitOn "/" name of + case splitOn '/' name of grp : rest -> Just (grp, concat rest) _ -> Nothing diff --git a/test/Main.hs b/test/Main.hs index 66fff4b..8246c45 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -4,9 +4,13 @@ module Main where import Data.Function (on) import Data.List -import Data.List.Split (splitOn) +import Data.Functor.Identity (runIdentity) -- import Data.Maybe (catMaybes) -- import System.Process.Typed (readProcess_) + +import qualified Streamly.Prelude as Stream +import qualified Streamly.Data.Fold as Fold + import BenchShow -- import qualified Data.Text.Lazy as T @@ -26,6 +30,11 @@ packages = , "drinkery" ] +splitOn :: Eq a => a -> [a] -> [[a]] +splitOn d = + runIdentity + . Stream.toList . Stream.splitOn (== d) Fold.toList . Stream.fromList + ------------------------------------------------------------------------------- main :: IO () main = do @@ -70,7 +79,7 @@ main = do , "transformation/scan" ] bsort bs = - let i = intersect (map (last . splitOn "/") prefixes) bs + let i = intersect (map (last . splitOn '/') prefixes) bs in i ++ (bs \\ i) cfg = defaultConfig { mkTitle = Just (\_ -> chartTitle) @@ -78,7 +87,7 @@ main = do , classifyBenchmark = \bm -> case any (`isPrefixOf` bm) prefixes of True -> - let xs = reverse (splitOn "/" bm) + let xs = reverse (splitOn '/' bm) in Just (suffixVersion (xs !! 0), xs !! 1) False -> Nothing , selectBenchmarks = \g -> bsort $ From f223d570f2fd9c2161a9b7429000977c0e804fc8 Mon Sep 17 00:00:00 2001 From: Adithya Kumar Date: Thu, 27 Jan 2022 17:49:24 +0530 Subject: [PATCH 2/2] Update to latest stack resolver and add streamly to extra-deps --- stack.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stack.yaml b/stack.yaml index 3331aa4..315c2d6 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,3 +1,6 @@ -resolver: lts-16.11 +resolver: lts-18.23 packages: - '.' +extra-deps: + - streamly-0.8.1.1 + - unicode-data-0.2.0