on b842e2f help sign in
vty/test/BenchImageFuzz.hs
31 lines 679 B history raw
1{-# LANGUAGE MultiWayIf #-}
2module BenchImageFuzz where
3import Graphics.Vty
4import Graphics.Vty.Debug
6import Verify.Graphics.Vty.Image
7import Verify
9import Control.Applicative
10import Control.Monad
12import System.Random
14rand :: Arbitrary a => IO a
15rand = head <$> sample' arbitrary
17random_image w h = do
18 SingleAttrSingleSpanStack i _ _ _ <- rand
19 return i
21random_picture w h = pic_for_image <$> random_image w h
23bench_0 = do
24 vty <- mkVty
25 DisplayRegion w h <- display_bounds $ terminal vty
26 let pictures = replicateM 100 (random_picture w h)
27 bench ps = do
28 forM ps (update vty)
29 shutdown vty
30 return $ Bench pictures bench