mirror of
https://github.com/ilyakooo0/vty.git
synced 2024-11-29 08:49:40 +03:00
39 lines
1.3 KiB
Haskell
39 lines
1.3 KiB
Haskell
-- 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.
|
|
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
|