[Haskell-cafe] Reducing CPU load when using Helm

Kaspar Emanuel kaspar.bumke at gmail.com
Tue Aug 19 20:52:13 UTC 2014


On 18 August 2014 20:24, Kaspar Emanuel <kaspar.bumke at gmail.com> wrote:
> Hi,
>
> are there some simple tricks to reduce the CPU load? This simple
> square rendering sits at 20% CPU even when the window size remains
> constant.
>
> import FRP.Helm
> import qualified FRP.Helm.Window as Window
>
> render :: (Int, Int) -> Element
> render (w, h) = collage w h [move (100, 100) $ filled red $ square 64]
>
> main :: IO ()
> main = do
>     engine <- startup defaultConfig
>     run engine $ render <~ Window.dimensions engine
>
> The binary fractal tree  I submitted in another thread on helm-dev
> sits at 100% CPU  when the mouse isn't moving. It seems to me that
> Helm keeps re-drawing and re-computing when it doesn't need to.
>
> I started digging through the source a bit but it will take me a while
> to understand Elerea and how it samples the inputs and causes things
> to update.
>
> Are there any quick fixes?
>

So I tried stepping the render function using a time-constant. But
that just causes the resulting programs to freeze on the first frame.

https://github.com/kasbah/helm/commit/9ef9607d8057100b5b7930fa2b5e85c6040d1a44

I modified the driveNetwork function from here:
www.formicite.com/dopage.php?frp/frp.html

Bit out of my element with this stuff. I'd just like to _not_ max out
the CPU with simple graphical programs.


More information about the Haskell-Cafe mailing list