-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Performance #5
Comments
Hi Roman, Yes, I want to make it faster, and thank you for diagnosing the time spent in ratoms. That is surprising to me because the ratoms should just be a mechanism to trigger re-rendering. Maybe using React local-state would be better for the interpolation part. Pull requests are very welcome, and it would be great if we can collaborate on how to solve this. I think the rough plan based on your findings is:
I'll give this a shot sometime this weekend. I think in principle we should be able to achieve the same performances as Regards, |
Hello! I tried to run the dev build, but I got a lot of errors. I ended up copying the file down and tried testing some changes. Here's what I came up with: Test code: (def left (r/atom 0))
(defn runner []
(let [s (g/spring left)]
(fn []
[:div {:style {:position :absolute
:left @s}}
"x"])))
(defn benchmark []
[:div {:style {:position :relative}}
(for [n (range 100)]
^{:key n} [runner])
[:div {:style {:padding-top 50}}
[:button {:on-click #(swap! left + 50)} "Go!"]]]) Procedure: Load page, start timeline, click "Go!", wait till they stop, then repeat 2 more times. Results (Averages):
I noticed the small function was using js/Math.abs, which I don't believe is necessary. Moving to a comparison function increased the speed by over 10%. See the following benchmarks: (time (dotimes [n 10000000] (< -0.1 -0.0000001 0.1))))
"Elapsed time: 8.000000 msecs"
(time (dotimes [n 10000000] (< (js/Math.abs -0.0000001) 0.1)))
"Elapsed time: 1190.000000 msecs" I'd be happy to work on pull request for just these if you're open to accepting them. I also have quite a few other changes I'd like to make, I'm not sure how open you are to changes in the api :). If not, I can fork it for now and just try them out on my own! EDIT: rewrote |
Hi Ben, That's awesome. Yes please send a pull request and I'll merge it. Thank you! Regards, |
Hi. Thank you very much for this library! I've been looking for something like this to work with Reagent.
I've noticed that animations are not quite smooth and after profiling in DevTools I can see that perf is not very good since FPS is lower than 60.
My question is: do you plan to work more on perf improvements? Is there any way I can help you?
From what I've seen I can say that most of the time per frame is spent in Reagent atoms. Seems like minimising usage of atoms would help. Also I'm not quite sure why are you using
setTimeout
inspring
, shouldn't it berequestAnimationFrame
?Currently I'm using JavaScript library
react-motion
, the perf there is better but the API is not very comfortable to use with Reagent. So I'm really looking forward to this library. Thanks!The text was updated successfully, but these errors were encountered: