mirror of
https://github.com/ilyakooo0/vty.git
synced 2024-11-29 16:54:42 +03:00
7b38759846
Ignore-this: 1d31bef2e227fefafe8bb4b6f9511e1d darcs-hash:20090904172928-f0a0d-987b6931294fd33f7825eddc0adf04c81716a4dd.gz
33 lines
1.2 KiB
Haskell
33 lines
1.2 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.
|
|
-}
|
|
import Graphics.Vty
|
|
|
|
import Control.Monad ( forM_ )
|
|
|
|
import System.Time
|
|
|
|
main = do
|
|
vty <- mkVty
|
|
(w, h) <- getSize vty
|
|
let test_chars = take 500 $ cycle $ [ c | c <- ['a'..'z']]
|
|
start_time_0 <- getClockTime
|
|
forM_ test_chars $ \test_char -> do
|
|
let test_image = test_image_using_renderChar test_char w h
|
|
out_pic = pic { pImage = test_image }
|
|
update vty out_pic
|
|
end_time_0 <- getClockTime
|
|
let start_time_1 = end_time_0
|
|
forM_ test_chars $ \test_char -> do
|
|
let test_image = renderFill attr test_char w h
|
|
out_pic = pic { pImage = test_image }
|
|
update vty out_pic
|
|
end_time_1 <- getClockTime
|
|
shutdown vty
|
|
putStrLn $ timeDiffToString $ diffClockTimes end_time_0 start_time_0
|
|
putStrLn $ timeDiffToString $ diffClockTimes end_time_1 start_time_1
|
|
|
|
test_image_using_renderChar c w h = vertcat $ replicate h $ horzcat $ map (renderChar attr) (replicate w c)
|
|
|