Hi everyone, I am looking for suggestions to reduce cpu usage of my app.
I have a game similar to bingo.
I have cards that contains 4 rows one for the title and the others for the number cells
each row contains 9 cells 5 of them with numbers 4 empty
something like this
| title | |num|num|empty|empty|...| |empty|num|num|... | |... |
the rows that contain select numbers are highlighted
so I have something like this
type Card = Card Int (List Int) (List Int) (List Int) -- Card id row1 row2 row3 type alias Cards = List Card drawCard:List Int -> Cards -> Element msg drawCard selectedBalls = List.map (\Card id r1 r2 r3 -> Element.column[ header id, List.map (cell r1 selectedBalls) |> Element.row List.map (cell r2 selectedBalls) |> Element.row List.map (cell r3 selectedBalls) |> Element.row ]) cell:List Int->Int->Element msg cell existingBalls num = if num == 0 then E.el [ --styling ] E.none else String.fromInt num |> E.text |> center |> E.el [ Font.color <| if List.member num existingBalls then Color.white else Color.black , Bg.color <| if List.member num existingBalls then Color.black else Color.white ]
The code works just fine but the performance is horrible when the game starts to be faster the cpu usage skyrockets do you have any suggestions how can I refactor the thing or what can i do to increase the performance