Skip to content
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: speed up drawing. #8

Open
davidbau opened this issue Aug 26, 2013 · 3 comments
Open

Performance: speed up drawing. #8

davidbau opened this issue Aug 26, 2013 · 3 comments

Comments

@davidbau
Copy link
Member

Currently the animation of the turtle sprite is a bottleneck for performance: you can't go faster than a few hundred moves per second. That is because each time the turtle is moved and a new line segment is drawn, its current position is recomputed in a pretty slow way. (The 2d transforms are zeroed, then the untransformed position is read, then the 2d transforms are reapplied, and the math is done in parallel by hand to see exactly where the transform-origin of the turtle is on the screen.)

We should investigate ways to speed it up, e.g.,:

  • Assume that the untransformed position doesn't change under certain conditions.
  • And in those cases assume that we can just cache and read position data on the side instead of deriving it from the dom.
@davidbau
Copy link
Member Author

Relative turtle motions have now been sped up by about tenfold - for example, a classic "fern" fractal example that used to take about 20 seconds to render can be done in one second (which is still not fast enough, but at least it's faster than before). Absolute turtle motions are still slow; these need to be sped up next.

The compromise made is that, as long as a pen is down, the pen location is not sensitive to parent element transformation changes. The parent transforms are read again when the pen is up.

@theanandramakrishna
Copy link

Was there a commit for this that I missed? I got the notification, but don't see a commit for me to review.

@davidbau
Copy link
Member Author

davidbau commented Feb 2, 2014

For future reference: here are the diffs for perf improvements so far:
7d2bfb7...79071e9

I'm leaving this issue open until absolute positioning (e.g., moveto) is similarly fast.

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

No branches or pull requests

2 participants