vty/test/BenchRenderChar.hs

39 lines
1.3 KiB
Haskell
Raw Normal View History

2017-01-22 20:22:15 +03:00
-- benchmarks composing images using the renderChar operation. This is
-- what Yi uses in Yi.UI.Vty.drawText. Ideally a sequence of renderChar
-- images horizontally composed should provide no worse performance than
-- a fill render op.
2013-01-28 09:41:59 +04:00
module BenchRenderChar where
import Graphics.Vty
import Verify
import Control.Monad ( forM_ )
bench0 = do
vty <- mkVty defaultConfig
(w,h) <- displayBounds $ outputIface vty
let testChars = return $ take 500 $ cycle $ [ c | c <- ['a'..'z']]
bench d = do
forM_ d $ \testChar -> do
let testImage = testImageUsingChar testChar w h
outPic = picForImage testImage
update vty outPic
shutdown vty
return $ Bench testChars bench
testImageUsingChar c w h
= vertCat $ replicate (fromIntegral h)
$ horizCat $ map (char defAttr) (replicate (fromIntegral w) c)
bench1 = do
vty <- mkVty defaultConfig
(w,h) <- displayBounds $ outputIface vty
let testChars = return $ take 500 $ cycle $ [ c | c <- ['a'..'z']]
bench d = do
forM_ d $ \testChar -> do
let testImage = charFill defAttr testChar w h
outPic = picForImage testImage
update vty outPic
shutdown vty
return $ Bench testChars bench