From cecb100fc35d70f3de61178f141351b0863ec2d8 Mon Sep 17 00:00:00 2001 From: vidsinghal Date: Mon, 8 Jan 2024 19:52:14 -0500 Subject: [PATCH] Add ghc bench that's in the paper --- .../examples/layout_bench/Ghc/ghc.zip | Bin 0 -> 19409 bytes .../examples/layout_bench/Ghc/ghc/MainGhc.hs | 682 ++++++++++++++++++ .../Ghc/ghc/layout1ContentSearch.hs | 27 + .../layout_bench/Ghc/ghc/layout1FindBlogs.hs | 20 + .../layout_bench/Ghc/ghc/layout1TagSearch.hs | 26 + .../Ghc/ghc/layout2ContentSearch.hs | 26 + .../layout_bench/Ghc/ghc/layout2FindBlogs.hs | 21 + .../layout_bench/Ghc/ghc/layout2TagSearch.hs | 27 + .../Ghc/ghc/layout3ContentSearch.hs | 22 + .../layout_bench/Ghc/ghc/layout3FindBlogs.hs | 20 + .../layout_bench/Ghc/ghc/layout3TagSearch.hs | 30 + .../Ghc/ghc/layout4ContentSearch.hs | 22 + .../layout_bench/Ghc/ghc/layout4FindBlogs.hs | 20 + .../layout_bench/Ghc/ghc/layout4TagSearch.hs | 26 + .../Ghc/ghc/layout5ContentSearch.hs | 22 + .../layout_bench/Ghc/ghc/layout5FindBlogs.hs | 21 + .../layout_bench/Ghc/ghc/layout5TagSearch.hs | 26 + .../Ghc/ghc/layout6ContentSearch.hs | 22 + .../layout_bench/Ghc/ghc/layout6FindBlogs.hs | 21 + .../layout_bench/Ghc/ghc/layout6TagSearch.hs | 26 + .../Ghc/ghc/layout7ContentSearch.hs | 23 + .../layout_bench/Ghc/ghc/layout7FindBlogs.hs | 21 + .../layout_bench/Ghc/ghc/layout7TagSearch.hs | 27 + .../Ghc/ghc/layout8ContentSearch.hs | 22 + .../layout_bench/Ghc/ghc/layout8FindBlogs.hs | 21 + .../layout_bench/Ghc/ghc/layout8TagSearch.hs | 26 + 26 files changed, 1247 insertions(+) create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc.zip create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/MainGhc.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1ContentSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1FindBlogs.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1TagSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2ContentSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2FindBlogs.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2TagSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3ContentSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3FindBlogs.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3TagSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4ContentSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4FindBlogs.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4TagSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5ContentSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5FindBlogs.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5TagSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6ContentSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6FindBlogs.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6TagSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7ContentSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7FindBlogs.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7TagSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8ContentSearch.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8FindBlogs.hs create mode 100644 gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8TagSearch.hs diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc.zip b/gibbon-compiler/examples/layout_bench/Ghc/ghc.zip new file mode 100644 index 0000000000000000000000000000000000000000..303f85217081780a5adb8e7c4a457919062748a5 GIT binary patch literal 19409 zcmb8X1ymhLv;~U0ySux)6Wrb1-95Mk0)gNfT!Xu7AUFhfhY(zY1@bR5^WKMK=Ks8~ za#!E(y8G1X-E~gYKBrny1{4ei=;3M`pgq)IzZR1N;&2590@?;##{K8lwnknKZmt}n4)(5Q_O2>s zM$RUd43;kc3;G273uw8@noKVflHZAe6PyvPW;LS#+(GY;zA6^QwO3>^4mOtQ31ntt zovSjl3B;mC-i*X^!yebZ*J^C#lNbc4vDf6`R6T|CgpRFBEh)n`raHhyWj^bCcaQQH>hQ{2cT#L;=BSbt1XyRWP01> z<7!8zDK2!`AdW+A#g21L4jL?bF)8=mH|ey+!A)0k8En~Bg1QSK|B+sV6eU{YosFby z#_q@)1-y`~+cf?KFZ7>@d#HnlB*BCpvP)bY@v)tUuN6-H$Qp0okVs_{5BHSDFT;=% zpKF|ddkq}#>2Wa|EaH{rd0p_Ss3b#p#Al^Ze%u!f2X%kjdP=26r9IbVkdAQ*ivd+L zcY7zZnBE$Zg%lMHmV4l$XSO+;8PWPXkNH+3lLXFPeWq^%PqHIO9^TGk(l&*}+)pEj zkklSas@Wc`E~CqOqs1Gf)#x}+j>rz6mqb$RQSli7h)e|o0>XSjB(u1cy{U+;gN4g; z5;=b-v0YWprk4q>{j0_s7E9P+%?h)XoWtOnsGiv+tUkGfMYhDZO?;Cfo*b7`bwxf$ZSkz6?c8#BJ1L7k~HW$I81k`nY^w zC!I6O)`WEkZ|ccNH%*&BrJpbaQG~)Lnuk%Y=19j}(+!^CKUc0zp-;TOFuvsL!>g1| zXLKMSWqTkXgn#&wGqSRmurzs2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7OGw_$I?&sj+JkP=ZWexskx98<*@VS8$zUKyh zSsVUY?_aK4o`cH(rW{W(`|kCl@_&JY1LoF1KsbOucW59W JF_EWl{}1!ZV>bW* literal 0 HcmV?d00001 diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/MainGhc.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/MainGhc.hs new file mode 100644 index 000000000..2e9ce79e8 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/MainGhc.hs @@ -0,0 +1,682 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE Strict #-} +module MainGhc where + +import System.TimeIt +import System.CPUTime +import qualified Data.Vector as V +import System.Random +import Data.Time.Clock (getCurrentTime, diffUTCTime) +import Control.Exception (evaluate) + +import qualified Language.Haskell.TH as TH + +--import Text.StringRandom + +import Control.DeepSeq +import Data.Int +import Data.List +import Text.Printf + +import Control.Monad +import System.IO.Unsafe + +data PList a = Nil | Cons a (PList a) deriving (Show) + +type Text = String + +-- For simplicity, we are assuming for this benchmark that data Inline is tokenized at the "word" level. +-- Therefore, The Base case where "Text" is used is going to be a single word, i.e, "Str Text". +data Inline = Str Text + | Emph (PList Inline) + -- | Underline (PList Inline) + -- | Strong (PList Inline) + -- | Strikeout (PList Inline) + -- | Superscript (PList Inline) + -- | Subscript (PList Inline) + -- | SmallCaps (PList Inline) + -- | Quoted QuoteType (PList Inline) + -- | Cite [Citation] (PList Inline) + -- | Code Attr Text + | Space + -- | SoftBreak + -- | LineBreak + -- | Math MathType Text + -- | RawInline Format Text + -- | Link Attr (PList Inline) Target + -- | Image Attr (PList Inline) Target + -- | Note (PList Block) + -- | Span Attr (PList Inline) + deriving (Show) + +data Block = Plain (PList Inline) + -- | Para (PList Inline) + -- | LineBlock (PList (PList Inline)) + -- | CodeBlock Attr Text + -- | RawBlock Format Text + -- | BlockQuote (PList Block) + -- | OrderedList ListAttributes [[Block]] + -- | BulletList (PList (PList Block)) + -- | DefinitionList PList ( PList Inline , PList (PList Block) ) ---> This is resulting in a compile time error (TODO: DEBUG) + -- | Header Int Attr (PList Inline) + -- | HorizontalRule + -- | Table Attr Caption [ColSpec] TableHead [TableBody] TableFoot + -- | Div Attr (PList Block) + | Null + deriving (Show) + +-- Define Blog elements +data BlogHeader = Header Text deriving (Show) +data BlogId = ID Int deriving (Show) +data BlogAuthor = Author Text deriving (Show) +data BlogDate = Date Text deriving (Show) +data BlogContent = Content Block deriving (Show) +data BlogTags = TagList (PList Text) deriving (Show) + +-- Define packed Blog data Type/s, we can arrange the fields here to change their relative ordering. +data Blog = End + | Layout1 (BlogHeader) (BlogId) (BlogAuthor) (BlogDate) (BlogContent) (BlogTags) (Blog) + | Layout2 (BlogContent) (BlogTags) (Blog) (BlogHeader) (BlogId) (BlogAuthor) (BlogDate) + | Layout3 (BlogTags) (Blog) (BlogContent) (BlogHeader) (BlogId) (BlogAuthor) (BlogDate) + | Layout4 (BlogTags) (BlogContent) (Blog) (BlogHeader) (BlogId) (BlogAuthor) (BlogDate) + | Layout5 (Blog) (BlogTags) (BlogContent) (BlogHeader) (BlogId) (BlogAuthor) (BlogDate) + | Layout6 (BlogHeader) (BlogId) (BlogAuthor) (BlogDate) (BlogContent) (Blog) (BlogTags) + | Layout7 (Blog) (BlogContent) (BlogHeader) (BlogId) (BlogAuthor) (BlogDate) (BlogTags) + | Layout8 (BlogContent) (Blog) (BlogId) (BlogAuthor) (BlogDate) (BlogHeader) (BlogTags) + deriving (Show) + +getChar' :: Int -> Char +getChar' decimal = + if decimal == 0 then '!' + else if decimal == 1 then '#' + else if decimal == 2 then '$' + else if decimal == 3 then '%' + else if decimal == 4 then '&' + else if decimal == 5 then '(' + else if decimal == 6 then ')' + else if decimal == 7 then '*' + else if decimal == 8 then '+' + else if decimal == 9 then ',' + else if decimal == 10 then '-' + else if decimal == 11 then '.' + else if decimal == 12 then '/' + else if decimal == 13 then '0' + else if decimal == 14 then '1' + else if decimal == 15 then '2' + else if decimal == 16 then '3' + else if decimal == 17 then '4' + else if decimal == 18 then '5' + else if decimal == 19 then '6' + else if decimal == 20 then '7' + else if decimal == 21 then '8' + else if decimal == 22 then '9' + else if decimal == 23 then ':' + else if decimal == 24 then ';' + else if decimal == 25 then '<' + else if decimal == 26 then '=' + else if decimal == 27 then '>' + else if decimal == 28 then '?' + else if decimal == 29 then '@' + else if decimal == 30 then 'A' + else if decimal == 31 then 'B' + else if decimal == 32 then 'C' + else if decimal == 33 then 'D' + else if decimal == 34 then 'E' + else if decimal == 35 then 'F' + else if decimal == 36 then 'G' + else if decimal == 37 then 'H' + else if decimal == 38 then 'I' + else if decimal == 39 then 'J' + else if decimal == 40 then 'K' + else if decimal == 41 then 'L' + else if decimal == 42 then 'M' + else if decimal == 43 then 'N' + else if decimal == 44 then 'O' + else if decimal == 45 then 'P' + else if decimal == 46 then 'Q' + else if decimal == 47 then 'R' + else if decimal == 48 then 'S' + else if decimal == 49 then 'T' + else if decimal == 50 then 'U' + else if decimal == 51 then 'V' + else if decimal == 52 then 'W' + else if decimal == 53 then 'X' + else if decimal == 54 then 'Y' + else if decimal == 55 then 'Z' + else if decimal == 56 then '[' + else if decimal == 57 then ']' + else if decimal == 58 then '^' + else if decimal == 59 then '_' + else if decimal == 60 then '`' + else if decimal == 61 then 'a' + else if decimal == 62 then 'b' + else if decimal == 63 then 'c' + else if decimal == 64 then 'd' + else if decimal == 65 then 'e' + else if decimal == 66 then 'f' + else if decimal == 67 then 'g' + else if decimal == 68 then 'h' + else if decimal == 69 then 'i' + else if decimal == 70 then 'j' + else if decimal == 71 then 'k' + else if decimal == 72 then 'l' + else if decimal == 73 then 'm' + else if decimal == 74 then 'n' + else if decimal == 75 then 'o' + else if decimal == 76 then 'p' + else if decimal == 77 then 'q' + else if decimal == 78 then 'r' + else if decimal == 79 then 's' + else if decimal == 80 then 't' + else if decimal == 81 then 'u' + else if decimal == 82 then 'v' + else if decimal == 83 then 'w' + else if decimal == 84 then 'x' + else if decimal == 85 then 'y' + else if decimal == 86 then 'z' + else if decimal == 87 then '{' + else if decimal == 88 then '|' + else if decimal == 89 then '}' + else '~' + +mkChar :: Int -> StdGen -> Char +mkChar val r = let (val, _) = randomR (0, 91 :: Int) r + in getChar' val + +-- Get a random word, Int is the length of the string. +-- Based on internet, average english word is 5 characters long +getRandomString :: Int -> Text +getRandomString length = unsafePerformIO $ randString + +-- A standard function generating random strings. +randString :: IO String +randString = liftM (take 5 . randomRs ('a','z')) newStdGen + +-- A standard function generating random strings. +randStrinContent :: IO String +randStrinContent = liftM (take 1 . randomRs ('a','z')) newStdGen + +randInt :: IO Int +randInt = liftM (mod 4 . head . take 1 . randomRs (0, maxBound :: Int)) newStdGen + +randStringTag :: IO String +randStringTag = liftM (take 1 . randomRs ('a','z')) newStdGen + +-- .. lifted to Q +randStringQ :: TH.Q String +randStringQ = TH.runIO randString + +-- .. lifted to an Q Exp +randStringExp :: TH.Q TH.Exp +randStringExp = randStringQ >>= TH.litE . TH.stringL + +-- | Declares a constant `String` function with a given name +-- that returns a random string generated on compile time. +randStringD :: String -> TH.DecsQ +randStringD fname = liftM (: []) $ + TH.funD (TH.mkName fname) [TH.clause [] (TH.normalB randStringExp) []] + + +-- Utility Functions to make Blogs and its Elements. +mkBlogHeader :: Text -> BlogHeader +mkBlogHeader text = Header text + +mkBlogID :: Int -> BlogId +mkBlogID val = ID val + +mkBlogAuthor :: Text -> BlogAuthor +mkBlogAuthor text = Author text + +mkBlogDate :: Text -> BlogDate +mkBlogDate text = Date text + +mkBlogContent :: Block -> BlogContent +mkBlogContent block = Content block + +mkBlogTags :: (PList Text) -> BlogTags +mkBlogTags taglist = TagList taglist + + +checkBlogID :: BlogId -> Int -> Bool +checkBlogID id val = case id of + ID x -> if ( x == val ) then True + else False + +-- Function to compare two words, each represented by String. +compareWord :: Text -> Text -> Bool +compareWord word1 word2 = + let len1 = length word1 + len2 = length word2 + compare_len = if (len1 == len2) then True else False + in if (compare_len) then (cmp 0 len1 word1 word2) else False + +-- Compare 2 String (Text) or words for equality if their length is the same. +cmp :: Int -> Int -> String -> String -> Bool +cmp start end word1 word2 = + if (start < end) then + let a = word1 !! start + b = word2 !! start + eq = if (a == b) then True else False + recurse = cmp (start+1) end word1 word2 + in (eq && recurse) + else True + +-- Search a TagList (PList Text) for some keyword +searchTagList :: Text -> PList Text -> Bool +searchTagList keyword taglist = case taglist of + Nil -> False + Cons word rst -> (compareWord keyword word) || (searchTagList keyword rst) + +-- delete a keyword in a TagList +deleteTagList :: Text -> PList Text -> PList Text +deleteTagList keyword taglist = case taglist of + Nil -> Nil + Cons word rst -> if (compareWord keyword word) then (deleteTagList keyword rst) + else Cons word (deleteTagList keyword rst) + + +insertTagList :: Text -> PList Text -> PList Text +insertTagList keyword taglist = case taglist of + Nil -> (Cons keyword) Nil + Cons word rst -> insertTagList keyword rst + +-- Tell if a particular keyword exists in a Block data type or not +isKeywordPresentInBlock :: Text -> Block -> Bool +isKeywordPresentInBlock keyword contentBlock = + case contentBlock of + Plain list_inline -> (searchInlineListForKeyword keyword list_inline) + --Para list_inline -> (searchInlineListForKeyword keyword list_inline) + --BlockQuote list_block -> (searchBlockListForKeyword keyword list_block) + --HorizontalRule -> False + Null -> False + +-- Tell if a particular keyword exists in an inline data type or not. (search a Inline) +isKeywordPresentInline :: Text -> Inline -> Bool +isKeywordPresentInline keyword inline = + case inline of + Str text -> (compareWord keyword text) + Emph list_inline -> (searchInlineListForKeyword keyword list_inline) + --Underline list_inline -> (searchInlineListForKeyword keyword list_inline) + --Strong list_inline -> (searchInlineListForKeyword keyword list_inline) + --Strikeout list_inline -> (searchInlineListForKeyword keyword list_inline) + --Superscript list_inline -> (searchInlineListForKeyword keyword list_inline) + --Subscript list_inline -> (searchInlineListForKeyword keyword list_inline) + --SmallCaps list_inline -> (searchInlineListForKeyword keyword list_inline) + Space -> False + --SoftBreak -> False + --LineBreak -> False + --Note list_block -> (searchBlockListForKeyword keyword list_block) + +-- Search a block list for a particular keyword +searchBlockListForKeyword :: Text -> PList Block -> Bool +searchBlockListForKeyword keyword block_list = + case block_list of + Nil -> False + Cons block rst -> (isKeywordPresentInBlock keyword block) || (searchBlockListForKeyword keyword rst) + +-- Search an Inline list for a particular keyword +searchInlineListForKeyword :: Text -> PList Inline -> Bool +searchInlineListForKeyword keyword inline_list = + case inline_list of + Nil -> False + Cons inline rst -> (isKeywordPresentInline keyword inline) || (searchInlineListForKeyword keyword rst) + +-- Emphasize a particular keyword in a Block type +emphasizeKeywordInBlock :: Text -> Block -> Block +emphasizeKeywordInBlock keyword contentBlock = + case contentBlock of + Plain list_inline -> Plain (emphasizeInlineListForKeyword keyword list_inline) + --Para list_inline -> Para (emphasizeInlineListForKeyword keyword list_inline) + --BlockQuote list_block -> BlockQuote (emphasizeKeywordInBlockList keyword list_block) + --HorizontalRule -> HorizontalRule + Null -> Null + +-- Emphasize a particular keyword in an Inline data type +emphasizeKeywordInline :: Text -> Inline -> Inline +emphasizeKeywordInline keyword inline = + case inline of + Str text -> let isSame = compareWord keyword text + --_ = printsym (quote "NEWLINE") + --_ = printbool isSame + --_ = printsym (quote "NEWLINE") + in if (isSame) then let + newlist :: PList Inline + newlist = (Cons (inline)) Nil + in (Emph newlist) + else inline + Emph list_inline -> Emph (emphasizeInlineListForKeyword keyword list_inline) + --Underline list_inline -> Underline (emphasizeInlineListForKeyword keyword list_inline) + --Strong list_inline -> Strong (emphasizeInlineListForKeyword keyword list_inline) + --Strikeout list_inline -> Strikeout (emphasizeInlineListForKeyword keyword list_inline) + --Superscript list_inline -> Superscript (emphasizeInlineListForKeyword keyword list_inline) + --Subscript list_inline -> Subscript (emphasizeInlineListForKeyword keyword list_inline) + --SmallCaps list_inline -> SmallCaps (emphasizeInlineListForKeyword keyword list_inline) + Space -> Space + --SoftBreak -> SoftBreak + --LineBreak -> LineBreak + --Note list_block -> Note (emphasizeKeywordInBlockList keyword list_block) + +-- Emphasize a particular keyword in an Inline list +emphasizeInlineListForKeyword :: Text -> PList Inline -> PList Inline +{-# INLINE emphasizeInlineListForKeyword #-} +emphasizeInlineListForKeyword keyword inline_list = + case inline_list of + Nil -> Nil + Cons inline rst -> let + newinline = emphasizeKeywordInline keyword inline + rst' = emphasizeInlineListForKeyword keyword rst + in Cons newinline rst' + +-- Emphasize a particular keyword in a block list +emphasizeKeywordInBlockList :: Text -> PList Block -> PList Block +emphasizeKeywordInBlockList keyword block_list = + case block_list of + Nil -> Nil + Cons block rst -> let + newBlock = emphasizeKeywordInBlock keyword block + rst' = emphasizeKeywordInBlockList keyword rst + in Cons newBlock rst' + + +searchBlogTags :: Text -> BlogTags -> Bool +searchBlogTags keyword tags = case tags of + TagList list -> searchTagList keyword list + + +deleteBlogTags :: Text -> BlogTags -> BlogTags +deleteBlogTags keyword tags = case tags of + TagList list -> TagList (deleteTagList keyword list) + +insertBlogTags :: Text -> BlogTags -> BlogTags +insertBlogTags keyword tags = case tags of + TagList list -> TagList (insertTagList keyword list) + +-- emphasize blog content, if present is True +emphasizeBlogContent' :: Text -> BlogContent -> BlogContent +emphasizeBlogContent' keyword oldContent = case oldContent of + Content block -> Content (emphasizeKeywordInBlock keyword block) + + + +emphasizeBlogContent :: Text -> BlogContent -> BlogContent +emphasizeBlogContent keyword oldContent = case oldContent of + Content block -> Content (emphasizeKeywordInBlock keyword block) + +searchBlogContent :: Text -> BlogContent -> Bool +searchBlogContent keyword content = case content of + Content block -> (isKeywordPresentInBlock keyword block) + +-- printWordList :: TextList -> Int -> Int -> () +-- printWordList vec start end = if start < end then +-- let +-- element = V.unsafeIndex vec start +-- _ = printVec (\i -> printchar i) element +-- in printWordList vec (start+1) end +-- else () + + +-- Make an Inline type, option chooses what kind of Inline data type we are creating +-- This creates all the base cases for the inline type +mkInlineBaseCase :: Int -> Inline +mkInlineBaseCase option = let + in if option == 0 then (Str (getRandomString 5)) -- get a random word + else Space + +-- Make a list of Inline data Type. +mkInlineList :: Int -> Int -> (PList Inline) +mkInlineList length base = + if length <= 0 then Nil + -- If its not base case, then don't stop recursion. + else if (base == 0) then + let item = Emph (mkInlineList 100 1) + rst = (mkInlineList (length - 1) base) + in Cons item rst + -- If its base case, then stop recursion in Inline data type and only add base cases. + else let item = (mkInlineBaseCase (unsafePerformIO $ randInt)) + rst = mkInlineList (length - 1) base + in Cons item rst + +mkRandomInlineList :: Int -> (PList Inline) +mkRandomInlineList len = if len <= 0 then Nil + else let word = Str (unsafePerformIO $ randStrinContent) + rst = mkRandomInlineList (len - 1) + in Cons word rst + +mkSomeTags :: Int -> PList Text +mkSomeTags len = if len <= 0 then Nil + else let word = ['a'] --unsafePerformIO $ randStringTag + rst = mkSomeTags (len - 1) + in Cons word rst + + +-- Make a list of blocks +mkBlockList :: Int -> Int -> (PList Block) +mkBlockList length base = + if length <= 0 then Nil + else if (base == 0) then + let item = (Plain (mkInlineList 1000 1)) + rst = (mkBlockList (length - 1) base) + in Cons item rst + else let item = Null + rst = (mkBlockList (length - 1) base) + in Cons item rst + + + +-------------------------------------------------------------------------------- +-- Timing things +-------------------------------------------------------------------------------- +median :: [Double] -> Double +median ls = (sort ls) !! (length ls `div` 2) +-------------------------------------------------------------------------------- + +-- -- Timing for making the layouts +-- dotrialMkLayout :: (Int -> Int -> Int -> Blog) -> Int -> Int -> Int -> IO (Blog, Double) +-- dotrialMkLayout f length id tag_len = do +-- t1 <- getCurrentTime +-- a <- evaluate $ (f length id tag_len) +-- t2 <- getCurrentTime +-- let delt = fromRational (toRational (diffUTCTime t2 t1)) +-- putStrLn ("iter time: " ++ show delt) +-- return $! (a,delt) + +-- benchMkLayout :: (Int -> Int -> Int -> Blog) -> Int -> Int -> Int -> Int -> IO (Blog, Double, Double) +-- benchMkLayout f length id tag_len iters = do +-- putStrLn ("Timings for making the particular layout") +-- tups <- mapM (\_ -> dotrialMkLayout f length id tag_len) [1..iters] +-- let (results, times) = unzip tups +-- let selftimed = median times +-- batchtime = sum times +-- return $! (last results, selftimed, batchtime) + +-- -- Timing for filtering the blogs based on a keyword +-- dotrialFilterBlogsBasedOnKeywordInTagList :: (Text -> Blog -> Blog) -> Text -> Blog -> IO (Blog, Double) +-- dotrialFilterBlogsBasedOnKeywordInTagList f keyword blogs = do +-- t1 <- getCurrentTime +-- a <- evaluate $ (f keyword blogs) +-- t2 <- getCurrentTime +-- let delt = fromRational (toRational (diffUTCTime t2 t1)) +-- putStrLn ("iter time: " ++ show delt) +-- return $! (a,delt) + +-- benchFilterBlogsBasedOnKeywordInTagList :: (Text -> Blog -> Blog) -> Text -> Blog -> Int -> IO (Blog, Double, Double) +-- benchFilterBlogsBasedOnKeywordInTagList f keyword blog iters = do +-- putStrLn ("Timings for filering blogs based on a keyword in the tag list") +-- tups <- mapM (\_ -> dotrialFilterBlogsBasedOnKeywordInTagList f keyword blog) [1..iters] +-- let (results, times) = unzip tups +-- let selftimed = median times +-- batchtime = sum times +-- return $! (last results, selftimed, batchtime) + +time :: IO t -> IO t +time a = do + start <- getCPUTime + v <- a + end <- getCPUTime + let diff = (fromIntegral (end - start)) / (10^12) + printf "Computation time: %0.6f sec\n" (diff :: Double) + return v + + +mkBlogs_layout1 :: Int -> Blog +mkBlogs_layout1 length = + if length < 0 then End + else + let header = (Header (getRandomString 5)) + id = (ID (10 - (mod length 10))) + author = (Author (getRandomString 5)) + date = (Date (getRandomString 5)) + content = (Content (Plain (mkRandomInlineList 50))) + tags = (TagList (mkSomeTags 10)) + rst = (mkBlogs_layout1 (length - 1)) + in Layout1 header id author date content tags rst + +mkBlogs_layout2 :: Int -> Blog +mkBlogs_layout2 length = + if length < 0 then End + else + let content = (Content (Plain (mkRandomInlineList 50))) + tags = (TagList (mkSomeTags 10)) + rst = (mkBlogs_layout2 (length - 1)) + header = (Header (getRandomString 5)) + id = (ID (10 - (mod length 10))) + author = (Author (getRandomString 5)) + date = (Date (getRandomString 5)) + in Layout2 content tags rst header id author date + +mkBlogs_layout3 :: Int -> Blog +mkBlogs_layout3 length = + if length < 0 then End + else + let tags = (TagList (mkSomeTags 10)) + rst = (mkBlogs_layout3 (length - 1)) + content = (Content (Plain (mkRandomInlineList 50))) + header = (Header (getRandomString 5)) + id = (ID (10 - (mod length 10))) + author = (Author (getRandomString 5)) + date = (Date (getRandomString 5)) + in Layout3 tags rst content header id author date + +mkBlogs_layout4 :: Int -> Blog +mkBlogs_layout4 length = + if length < 0 then End + else + let tags = (TagList (mkSomeTags 10)) + content = (Content (Plain (mkRandomInlineList 50))) + rst = (mkBlogs_layout4 (length - 1)) + header = (Header (getRandomString 5)) + id = (ID (10 - (mod length 10))) + author = (Author (getRandomString 5)) + date = (Date (getRandomString 5)) + in Layout4 tags content rst header id author date + +mkBlogs_layout5 :: Int -> Blog +mkBlogs_layout5 length = + if length < 0 then End + else + let rst = (mkBlogs_layout5 (length - 1)) + tags = (TagList (mkSomeTags 10)) + content = (Content (Plain (mkRandomInlineList 50))) + header = (Header (getRandomString 5)) + id = (ID (10 - (mod length 10))) + author = (Author (getRandomString 5)) + date = (Date (getRandomString 5)) + in Layout5 rst tags content header id author date + + +mkBlogs_layout6 :: Int -> Blog +mkBlogs_layout6 length = + if length < 0 then End + else + let header = (Header (getRandomString 5)) + id = (ID (10 - (mod length 10))) + author = (Author (getRandomString 5)) + date = (Date (getRandomString 5)) + content = (Content (Plain (mkRandomInlineList 50))) + rst = (mkBlogs_layout6 (length - 1)) + tags = (TagList (mkSomeTags 10)) + in Layout6 header id author date content rst tags + +mkBlogs_layout7 :: Int -> Blog +mkBlogs_layout7 length = + if length < 0 then End + else + let rst = (mkBlogs_layout7 (length - 1)) + content = (Content (Plain (mkRandomInlineList 50))) + header = (Header (getRandomString 5)) + id = (ID (10 - (mod length 10))) + author = (Author (getRandomString 5)) + date = (Date (getRandomString 5)) + tags = (TagList (mkSomeTags 10)) + in Layout7 rst content header id author date tags + + +mkBlogs_layout8 :: Int -> Blog +mkBlogs_layout8 length = + if length < 0 then End + else + let content = (Content (Plain (mkRandomInlineList 50))) + rst = (mkBlogs_layout8 (length - 1)) + id = (ID (10 - (mod length 10))) + author = (Author (getRandomString 5)) + date = (Date (getRandomString 5)) + header = (Header (getRandomString 5)) + tags = (TagList (mkSomeTags 10)) + in Layout8 content rst id author date header tags + + +blogLength :: Blog -> Int +blogLength blog = case blog of + End -> 0 + Layout1 _ _ _ _ _ _ rst -> 1 + blogLength rst + Layout2 _ _ rst _ _ _ _ -> 1 + blogLength rst + Layout3 _ rst _ _ _ _ _ -> 1 + blogLength rst + Layout4 _ _ rst _ _ _ _ -> 1 + blogLength rst + Layout5 rst _ _ _ _ _ _ -> 1 + blogLength rst + Layout6 _ _ _ _ _ rst _ -> 1 + blogLength rst + Layout7 rst _ _ _ _ _ _ -> 1 + blogLength rst + Layout8 _ rst _ _ _ _ _ -> 1 + blogLength rst + +benchFilterBlogsBasedOnKeywordInTagList :: (a -> b -> b) -> a -> b -> Int -> IO (b, Double, Double) +benchFilterBlogsBasedOnKeywordInTagList f keyword blog iters = do + putStrLn ("Timings for filering blogs based on a keyword in the tag list") + tups <- mapM (\_ -> dotrialFilterBlogsBasedOnKeywordInTagList f keyword blog) [1..iters] + let (results, times) = unzip tups + let selftimed = median times + batchtime = sum times + return $! (last results, selftimed, batchtime) + +-- Timing for filtering the blogs based on a keyword +dotrialFilterBlogsBasedOnKeywordInTagList :: (a -> b -> b) -> a -> b -> IO (b, Double) +dotrialFilterBlogsBasedOnKeywordInTagList f keyword blogs = do + t1 <- getCurrentTime + a <- evaluate $ (f keyword blogs) + t2 <- getCurrentTime + let delt = fromRational (toRational (diffUTCTime t2 t1)) + putStrLn ("iter time: " ++ show delt) + return $! (a,delt) + + +-- compile with +-- ghc MainGhc.hs -package V.Vector + + +-- Passes written so far +-- 1.) Search for a keyword in Content of Blogs +-- 2.) Search for a keyword in TagList of Blogs +-- 3.) Filter blogs based on a particular keyword +-- 4.) Filter blogs based on a particular keyword in the TagList +-- 5.) emphasize a particular keyword in the Content of Blogs + + +-- let blogs1 = mkBlogs_layout1 100 0 10 +-- blogs2 = mkBlogs_layout2 100 0 10 +-- blogs3 = mkBlogs_layout3 100 0 10 +-- blogs4 = mkBlogs_layout4 100 0 10 +-- keyword = getRandomString 2 +-- start <- getCPUTimeWithUnit +-- time1 = timeIt $ print (filterBlogsBasedOnKeywordInTagList keyword blogs1) +-- time2 = timeIt $ print (filterBlogsBasedOnKeywordInTagList keyword blogs2) +-- time3 = timeIt $ print (filterBlogsBasedOnKeywordInTagList keyword blogs3) +-- time4 = timeIt $ print (filterBlogsBasedOnKeywordInTagList keyword blogs4) +-- in time1 diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1ContentSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1ContentSearch.hs new file mode 100644 index 000000000..783b7fdc1 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1ContentSearch.hs @@ -0,0 +1,27 @@ +import MainGhc + +emphKeywordInContent :: Text -> Blog -> Blog +emphKeywordInContent keyword blogs = + case blogs of + End -> End + Layout1 header id author date content tags rst -> let --present = searchBlogContent keyword content + --_ = printsym (quote "NEWLINE") + --_ = printbool present + --_ = printsym (quote "NEWLINE") + newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + --_ = printsym (quote "NEWLINE") + --_ = printPacked newContent + --_ = printsym (quote "NEWLINE") + newRst = emphKeywordInContent keyword rst + in Layout1 header id author date newContent tags newRst + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout1 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInContent ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1FindBlogs.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1FindBlogs.hs new file mode 100644 index 000000000..6bdfeb7b4 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1FindBlogs.hs @@ -0,0 +1,20 @@ +import MainGhc + +insertKeywordInTagList :: Text -> Blog -> Blog +insertKeywordInTagList keyword blogs = case blogs of + End -> End + Layout1 header id author date content tags rst -> let present = searchBlogTags keyword tags + in if present then + let newRst = insertKeywordInTagList keyword rst + in Layout1 header id author date content tags newRst + else insertKeywordInTagList keyword rst + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout1 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList insertKeywordInTagList ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1TagSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1TagSearch.hs new file mode 100644 index 000000000..ff3634ef2 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout1TagSearch.hs @@ -0,0 +1,26 @@ +import MainGhc + +emphKeywordInTag :: Text -> Blog -> Blog +emphKeywordInTag keyword blogs = case blogs of + End -> End + Layout1 header id author date content tags rst -> let present = searchBlogTags keyword tags -- search the tags for the keyword + --_ = printbool present + in if (present) + then let newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInTag keyword rst + in Layout1 header id author date newContent tags newRst + else + let newRst = emphKeywordInTag keyword rst + in Layout1 header id author date content tags newRst + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout1 400000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInTag ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2ContentSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2ContentSearch.hs new file mode 100644 index 000000000..d9bb882a9 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2ContentSearch.hs @@ -0,0 +1,26 @@ +import MainGhc + +emphKeywordInContent :: Text -> Blog -> Blog +emphKeywordInContent keyword blogs = + case blogs of + End -> End + Layout2 content tags rst header id author date -> --let present = searchBlogContent keyword content + -- in + -- if present then + let newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInContent keyword rst + in Layout2 newContent tags newRst header id author date + -- else + -- let newRst = emphKeywordInContent keyword rst + -- in Layout2 content tags newRst header id author date + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout2 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInContent ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2FindBlogs.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2FindBlogs.hs new file mode 100644 index 000000000..0e90ddfe5 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2FindBlogs.hs @@ -0,0 +1,21 @@ +import MainGhc + + +insertKeywordInTagList :: Text -> Blog -> Blog +insertKeywordInTagList keyword blogs = case blogs of + End -> End + Layout2 content tags rst header id author date -> let present = searchBlogTags keyword tags + in if present then + let newRst = insertKeywordInTagList keyword rst + in Layout2 content tags newRst header id author date + else insertKeywordInTagList keyword rst + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout2 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList insertKeywordInTagList ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2TagSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2TagSearch.hs new file mode 100644 index 000000000..2a6948778 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout2TagSearch.hs @@ -0,0 +1,27 @@ +import MainGhc + +emphKeywordInTag :: Text -> Blog -> Blog +emphKeywordInTag keyword blogs = case blogs of + End -> End + Layout2 content tags rst header id author date -> let present = searchBlogTags keyword tags -- search the tags for the keyword + -- _ = printbool present + in if (present) + then let newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInTag keyword rst + in Layout2 newContent tags newRst header id author date + else + let newRst = emphKeywordInTag keyword rst + in Layout2 content tags newRst header id author date + + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout2 400000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInTag ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3ContentSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3ContentSearch.hs new file mode 100644 index 000000000..08e9bcda4 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3ContentSearch.hs @@ -0,0 +1,22 @@ +import MainGhc + +emphKeywordInContent :: Text -> Blog -> Blog +emphKeywordInContent keyword blogs = + case blogs of + End -> End + Layout3 tags rst content header id author date -> let --present = searchBlogContent keyword content + newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInContent keyword rst + in Layout3 tags newRst newContent header id author date + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout3 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInContent ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3FindBlogs.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3FindBlogs.hs new file mode 100644 index 000000000..5333d974a --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3FindBlogs.hs @@ -0,0 +1,20 @@ +import MainGhc + +insertKeywordInTagList :: Text -> Blog -> Blog +insertKeywordInTagList keyword blogs = case blogs of + End -> End + Layout3 tags rst content header id author date -> let present = searchBlogTags keyword tags + in if present then + let newRst = insertKeywordInTagList keyword rst + in Layout3 tags newRst content header id author date + else insertKeywordInTagList keyword rst + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout3 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList insertKeywordInTagList ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3TagSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3TagSearch.hs new file mode 100644 index 000000000..cdd3005cb --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout3TagSearch.hs @@ -0,0 +1,30 @@ +import MainGhc + +emphKeywordInTag :: Text -> Blog -> Blog +emphKeywordInTag keyword blogs = case blogs of + End -> End + Layout3 tags rst content header id author date -> let present = searchBlogTags keyword tags -- search the tags for the keyword + --_ = printbool present + in if present then + let + newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInTag keyword rst + in Layout3 tags newRst newContent header id author date + else + let + newRst = emphKeywordInTag keyword rst + in Layout3 tags newRst content header id author date + + + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout3 400000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInTag ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4ContentSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4ContentSearch.hs new file mode 100644 index 000000000..7da09842d --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4ContentSearch.hs @@ -0,0 +1,22 @@ +import MainGhc + +emphKeywordInContent :: Text -> Blog -> Blog +emphKeywordInContent keyword blogs = + case blogs of + End -> End + Layout4 tags content rst header id author date -> let --present = searchBlogContent keyword content + newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInContent keyword rst + in Layout4 tags newContent newRst header id author date + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout4 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInContent ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4FindBlogs.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4FindBlogs.hs new file mode 100644 index 000000000..e5cd722d5 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4FindBlogs.hs @@ -0,0 +1,20 @@ +import MainGhc + +insertKeywordInTagList :: Text -> Blog -> Blog +insertKeywordInTagList keyword blogs = case blogs of + End -> End + Layout4 tags content rst header id author date -> let present = searchBlogTags keyword tags + in if present then + let newRst = insertKeywordInTagList keyword rst + in Layout4 tags content newRst header id author date + else insertKeywordInTagList keyword rst + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout4 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList insertKeywordInTagList ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4TagSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4TagSearch.hs new file mode 100644 index 000000000..eafa341ac --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout4TagSearch.hs @@ -0,0 +1,26 @@ +import MainGhc + +emphKeywordInTag :: Text -> Blog -> Blog +emphKeywordInTag keyword blogs = case blogs of + End -> End + Layout4 tags content rst header id author date -> let present = searchBlogTags keyword tags + in if (present) then + let newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInTag keyword rst + in Layout4 tags newContent newRst header id author date + else + let newRst = emphKeywordInTag keyword rst + in Layout4 tags content newRst header id author date + + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout4 400000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInTag ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5ContentSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5ContentSearch.hs new file mode 100644 index 000000000..8228339fa --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5ContentSearch.hs @@ -0,0 +1,22 @@ +import MainGhc + +emphKeywordInContent :: Text -> Blog -> Blog +emphKeywordInContent keyword blogs = + case blogs of + End -> End + Layout5 rst tags content header id author date -> let --present = searchBlogContent keyword content + newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInContent keyword rst + in Layout5 newRst tags newContent header id author date + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout5 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInContent ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5FindBlogs.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5FindBlogs.hs new file mode 100644 index 000000000..e74f9b8c5 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5FindBlogs.hs @@ -0,0 +1,21 @@ +import MainGhc + +insertKeywordInTagList :: Text -> Blog -> Blog +insertKeywordInTagList keyword blogs = case blogs of + End -> End + Layout5 rst tags content header id author date -> let present = searchBlogTags keyword tags + in if present then + let newRst = insertKeywordInTagList keyword rst + in Layout5 newRst tags content header id author date + else insertKeywordInTagList keyword rst + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout5 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList insertKeywordInTagList ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5TagSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5TagSearch.hs new file mode 100644 index 000000000..08ad41b23 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout5TagSearch.hs @@ -0,0 +1,26 @@ +import MainGhc + +emphKeywordInTag :: Text -> Blog -> Blog +emphKeywordInTag keyword blogs = case blogs of + End -> End + Layout5 rst tags content header id author date -> let present = searchBlogTags keyword tags -- search the tags for the keyword + in if present then + let newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInTag keyword rst + in Layout5 newRst tags newContent header id author date + else + let newRst = emphKeywordInTag keyword rst + in Layout5 newRst tags content header id author date + + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout5 400000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInTag ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6ContentSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6ContentSearch.hs new file mode 100644 index 000000000..2a41d3ca4 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6ContentSearch.hs @@ -0,0 +1,22 @@ +import MainGhc + +emphKeywordInContent :: Text -> Blog -> Blog +emphKeywordInContent keyword blogs = + case blogs of + End -> End + Layout6 header id author date content rst tags -> let --present = searchBlogContent keyword content + newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInContent keyword rst + in Layout6 header id author date newContent newRst tags + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout6 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInContent ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6FindBlogs.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6FindBlogs.hs new file mode 100644 index 000000000..5f8369615 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6FindBlogs.hs @@ -0,0 +1,21 @@ +import MainGhc + +insertKeywordInTagList :: Text -> Blog -> Blog +insertKeywordInTagList keyword blogs = case blogs of + End -> End + Layout6 header id author date content rst tags -> let present = searchBlogTags keyword tags + in if present then + let newRst = insertKeywordInTagList keyword rst + in Layout6 header id author date content newRst tags + else insertKeywordInTagList keyword rst + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout6 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList insertKeywordInTagList ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6TagSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6TagSearch.hs new file mode 100644 index 000000000..e2477f497 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout6TagSearch.hs @@ -0,0 +1,26 @@ +import MainGhc + +emphKeywordInTag :: Text -> Blog -> Blog +emphKeywordInTag keyword blogs = case blogs of + End -> End + Layout6 header id author date content rst tags -> let present = searchBlogTags keyword tags -- search the tags for the keyword + in if present then + let newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInTag keyword rst + in Layout6 header id author date newContent newRst tags + else + let newRst = emphKeywordInTag keyword rst + in Layout6 header id author date content newRst tags + + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout6 400000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInTag ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7ContentSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7ContentSearch.hs new file mode 100644 index 000000000..4fb284d80 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7ContentSearch.hs @@ -0,0 +1,23 @@ +import MainGhc + +emphKeywordInContent :: Text -> Blog -> Blog +emphKeywordInContent keyword blogs = + case blogs of + End -> End + Layout7 rst content header id author date tags -> let --present = searchBlogContent keyword content + newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInContent keyword rst + in Layout7 newRst newContent header id author date tags + + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout7 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInContent ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7FindBlogs.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7FindBlogs.hs new file mode 100644 index 000000000..ad4f2113a --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7FindBlogs.hs @@ -0,0 +1,21 @@ +import MainGhc + +insertKeywordInTagList :: Text -> Blog -> Blog +insertKeywordInTagList keyword blogs = case blogs of + End -> End + Layout7 rst content header id author date tags -> let present = searchBlogTags keyword tags + in if present then + let newRst = insertKeywordInTagList keyword rst + in Layout7 newRst content header id author date tags + else insertKeywordInTagList keyword rst + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout7 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList insertKeywordInTagList ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7TagSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7TagSearch.hs new file mode 100644 index 000000000..e7dda9f40 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout7TagSearch.hs @@ -0,0 +1,27 @@ +import MainGhc + +emphKeywordInTag :: Text -> Blog -> Blog +emphKeywordInTag keyword blogs = case blogs of + End -> End + Layout7 rst content header id author date tags -> let present = searchBlogTags keyword tags -- search the tags for the keyword + in if present then + let newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInTag keyword rst + in Layout7 newRst newContent header id author date tags + else + let newRst = emphKeywordInTag keyword rst + in Layout7 newRst content header id author date tags + + + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout7 400000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInTag ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8ContentSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8ContentSearch.hs new file mode 100644 index 000000000..3e3086f87 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8ContentSearch.hs @@ -0,0 +1,22 @@ +import MainGhc + +emphKeywordInContent :: Text -> Blog -> Blog +emphKeywordInContent keyword blogs = + case blogs of + End -> End + Layout8 content rst id author date header tags -> let --present = searchBlogContent keyword content + newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInContent keyword rst + in Layout8 newContent newRst id author date header tags + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout8 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInContent ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8FindBlogs.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8FindBlogs.hs new file mode 100644 index 000000000..0c121aed2 --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8FindBlogs.hs @@ -0,0 +1,21 @@ +import MainGhc + +insertKeywordInTagList :: Text -> Blog -> Blog +insertKeywordInTagList keyword blogs = case blogs of + End -> End + Layout8 content rst id author date header tags -> let present = searchBlogTags keyword tags + in if present then + let newRst = insertKeywordInTagList keyword rst + in Layout8 content newRst id author date header tags + else insertKeywordInTagList keyword rst + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout8 1000000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList insertKeywordInTagList ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file diff --git a/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8TagSearch.hs b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8TagSearch.hs new file mode 100644 index 000000000..83622abae --- /dev/null +++ b/gibbon-compiler/examples/layout_bench/Ghc/ghc/layout8TagSearch.hs @@ -0,0 +1,26 @@ +import MainGhc + +emphKeywordInTag :: Text -> Blog -> Blog +emphKeywordInTag keyword blogs = case blogs of + End -> End + Layout8 content rst id author date header tags -> let present = searchBlogTags keyword tags -- search the tags for the keyword + in if present then + let newContent = case content of + Content block -> Content (emphasizeKeywordInBlock keyword block) + newRst = emphKeywordInTag keyword rst + in Layout8 newContent newRst id author date header tags + else + let newRst = emphKeywordInTag keyword rst + in Layout8 content newRst id author date header tags + + + + +-- main function +main :: IO () +main = + do let blogs1 = mkBlogs_layout8 400000 + (newblog1, self1, batch1) <- benchFilterBlogsBasedOnKeywordInTagList emphKeywordInTag ['a'] blogs1 1 + putStrLn $ "Length of new Blogs is: " + print (blogLength newblog1) + putStrLn $ "Done." \ No newline at end of file