@@ -1,4 +1,4 @@
1−module Main where
1+module BenchVerticalScroll where
22
33import Graphics.Vty hiding ( pad )
44
@@ -16,15 +16,9 @@ import System.Random
1616main = do
1717 let fixed_gen = mkStdGen 0
1818 setStdGen fixed_gen
19− args <- getArgs
20− case args of
21− [] -> mkVty >>= liftM2 (>>) (run $ Just 0) shutdown
22− ["--delay"] -> mkVty >>= liftM2 (>>) (run $ Just 1000000) shutdown
23− ["--slow"] -> mkVty >>= liftM2 (>>) (run Nothing ) shutdown
24− _ -> fail "usage: ./Bench [--slow|--delay]"
19+ mkVty >>= liftM2 (>>) run shutdown
2520
26−run (Just delay) vt = mapM_ (\p -> update vt p >> threadDelay delay) . benchgen =<< display_bounds (terminal vt)
27−run Nothing vt = mapM_ (update vt) (benchgen $ DisplayRegion 200 100)
21+run vt = mapM_ (\p -> update vt p) . benchgen =<< display_bounds (terminal vt)
2822
2923-- Currently, we just do scrolling.
3024takem :: (a -> Word) -> Word -> [a] -> ([a],[a])
@@ -54,9 +48,13 @@ pad :: Word -> Image -> Image
5448pad ml img = img <|> char_fill def_attr ' ' (ml - image_width img) 1
5549
5650clines :: StdGen -> Word -> [Image]
57−clines g maxll = map (pad maxll . horiz_cat . map (uncurry string)) $ fold (toEnum . length . snd) (lengths maxll g1) (nums g2)
51+clines g maxll = map (pad maxll . horiz_cat . map (uncurry string))
52+ $ fold (toEnum . length . snd) (lengths maxll g1) (nums g2)
5853 where (g1,g2) = split g
5954
6055benchgen :: DisplayRegion -> [Picture]
61−benchgen (DisplayRegion w h) = take 500 $ map ((\i -> pic_for_image i) . vert_cat . take (fromEnum h)) $ tails $ clines (mkStdGen 42) w
56+benchgen (DisplayRegion w h)
57+ = take 2000 $ map ((\i -> pic_for_image i) . vert_cat . take (fromEnum h))
58+ $ tails
59+ $ clines (mkStdGen 80) w
6260