on master help sign in
vty/test/BenchRenderChar.hs
38 lines 1.3 kB history raw
1-- benchmarks composing images using the renderChar operation. This is
2-- what Yi uses in Yi.UI.Vty.drawText. Ideally a sequence of renderChar
3-- images horizontally composed should provide no worse performance than
4-- a fill render op.
5module BenchRenderChar where
7import Graphics.Vty
8import Verify
10import Control.Monad ( forM_ )
12bench0 = do
13 vty <- mkVty defaultConfig
14 (w,h) <- displayBounds $ outputIface vty
15 let testChars = return $ take 500 $ cycle $ [ c | c <- ['a'..'z']]
16 bench d = do
17 forM_ d $ \testChar -> do
18 let testImage = testImageUsingChar testChar w h
19 outPic = picForImage testImage
20 update vty outPic
21 shutdown vty
22 return $ Bench testChars bench
24testImageUsingChar c w h
25 = vertCat $ replicate (fromIntegral h)
26 $ horizCat $ map (char defAttr) (replicate (fromIntegral w) c)
28bench1 = do
29 vty <- mkVty defaultConfig
30 (w,h) <- displayBounds $ outputIface vty
31 let testChars = return $ take 500 $ cycle $ [ c | c <- ['a'..'z']]
32 bench d = do
33 forM_ d $ \testChar -> do
34 let testImage = charFill defAttr testChar w h
35 outPic = picForImage testImage
36 update vty outPic
37 shutdown vty
38 return $ Bench testChars bench