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
|
2013-01-28 11:08:08 +04:00
|
|
|
|
2009-09-04 21:29:28 +04:00
|
|
|
import Graphics.Vty
|
2013-05-11 10:23:41 +04:00
|
|
|
import Verify
|
2009-09-04 21:29:28 +04:00
|
|
|
|
|
|
|
import Control.Monad ( forM_ )
|
|
|
|
|
2014-04-12 04:51:13 +04:00
|
|
|
bench0 = do
|
2017-01-24 22:46:14 +03:00
|
|
|
vty <- mkVty defaultConfig
|
2014-04-12 04:51:13 +04:00
|
|
|
(w,h) <- displayBounds $ outputIface vty
|
|
|
|
let testChars = return $ take 500 $ cycle $ [ c | c <- ['a'..'z']]
|
2013-05-11 10:23:41 +04:00
|
|
|
bench d = do
|
2014-04-12 04:51:13 +04:00
|
|
|
forM_ d $ \testChar -> do
|
|
|
|
let testImage = testImageUsingChar testChar w h
|
|
|
|
outPic = picForImage testImage
|
|
|
|
update vty outPic
|
2013-05-11 10:23:41 +04:00
|
|
|
shutdown vty
|
2014-04-12 04:51:13 +04:00
|
|
|
return $ Bench testChars bench
|
2009-09-04 21:29:28 +04:00
|
|
|
|
2017-01-22 09:21:58 +03:00
|
|
|
testImageUsingChar c w h
|
2014-04-12 04:51:13 +04:00
|
|
|
= vertCat $ replicate (fromIntegral h)
|
|
|
|
$ horizCat $ map (char defAttr) (replicate (fromIntegral w) c)
|
2009-09-04 21:29:28 +04:00
|
|
|
|
2014-04-12 04:51:13 +04:00
|
|
|
bench1 = do
|
2017-01-24 22:46:14 +03:00
|
|
|
vty <- mkVty defaultConfig
|
2014-04-12 04:51:13 +04:00
|
|
|
(w,h) <- displayBounds $ outputIface vty
|
|
|
|
let testChars = return $ take 500 $ cycle $ [ c | c <- ['a'..'z']]
|
2013-05-11 10:23:41 +04:00
|
|
|
bench d = do
|
2014-04-12 04:51:13 +04:00
|
|
|
forM_ d $ \testChar -> do
|
|
|
|
let testImage = charFill defAttr testChar w h
|
|
|
|
outPic = picForImage testImage
|
|
|
|
update vty outPic
|
2013-05-11 10:23:41 +04:00
|
|
|
shutdown vty
|
2014-04-12 04:51:13 +04:00
|
|
|
return $ Bench testChars bench
|