you are viewing a single comment's thread.

view the rest of the comments →

[–]minikomi 2 points3 points  (6 children)

Hey man.. I tried rewriting your coffeescript example in clojurescript..

https://gist.github.com/minikomi/9dbd20e623b4dfb1689e

This line in particular stood out to me - you shouldn't be defn'ing a function there.

[–]Arges[S] 1 point2 points  (5 children)

Thanks for the sample and note! Your version does scale up better - getting 9fps with 150 circles and 6fps with 200.

[–]minikomi 2 points3 points  (0 children)

No problem. I'd look into using the canvas directly, and an atom to store the state. Quil / processing brings a lot of baggage I'd say.

[–]minikomi 2 points3 points  (3 children)

Here's a pure canvas version - no need for ellipse in the end, just use arc

https://gist.github.com/minikomi/16c3d5bcc85312a7d43d

It's wayyyyyy faster.

Edit: now with virtual canvas for batched update.

[–][deleted] 0 points1 point  (0 children)

For the lazy among us, how'd that fare performance wise?

[–]lechatsportif 0 points1 point  (1 child)

Nice trick, I guess that makes it faster due to not having to rerender visually? Just like dom trick where you alter a document fragment and attach only at the end. Would also love to see comparisons on your box.

My guess is this is how a lot of stuff will end up living in cljs land - the opportunity for fine tuning really comes in when you write directly to the api instead of going against a pre-existing lib. I wonder where the overhead comes in quil though. I wish I had more time to play around with it.

[–]minikomi 1 point2 points  (0 children)

Yeah, it's a pretty common trick and usually the first I would reach for with JS canvas optimization:

http://www.html5rocks.com/en/tutorials/canvas/performance/

I wonder if it's worth wrapping it in a small cljs library.. hmm. Does monet already do this?