New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue with flow #372

Closed
sindikat opened this Issue Aug 26, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@sindikat

sindikat commented Aug 26, 2015

Consider this code (same code on Share-Elm.com):

import Graphics.Element as E exposing (Element, show)
import Mouse
import Signal exposing ((<~))

table = List.repeat 100 "-"

view : (Int, Int) -> Element
view (x,y) = E.flow E.down <| E.show (x,y) :: List.map (E.show) table

main = view <~ Mouse.position

Run this in elm-lang.org/try and try to move the mouse around. The mouse positions are updated very slowly and CPU usage becomes high. At first I thought it had to do with CSS transform actions translateX and translateY (a different variant of the code creates lots of these for every div), but now I suspect it has to do with constantly rewriting the DOM with each mouse movement.

Can that be considered a bug that should be fixed for Graphics.Element? (By implementing virtual-dom-style diffing or something like that?) If not, what is the idiomatic way to create lots of elements using Graphics.Element.flow, some of which will be changed according to signals? To explain: suppose I have a 2D game with a game grid 10x10, where tiles and objects might change during the game. If I have a view function that constantly redraws the game grid using flow, I have massive performance problems. But I have no idea how to workaround this, because I have to have view <~ foldp update model signal (or some form of that) in my main.

@sindikat sindikat changed the title from Performance issue with containers to Performance issue with flow Aug 26, 2015

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz May 11, 2016

Member

Sorry no one has gotten to this yet! With Elm 0.17, the Graphics.* modules have moved to evancz/elm-graphics so it makes sense to retarget issues there. I hope this will also mean it'll be easier to find folks to help handling them!

Member

evancz commented May 11, 2016

Sorry no one has gotten to this yet! With Elm 0.17, the Graphics.* modules have moved to evancz/elm-graphics so it makes sense to retarget issues there. I hope this will also mean it'll be easier to find folks to help handling them!

@evancz evancz closed this May 11, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment