paperjs / paper.js

The Swiss Army Knife of Vector Graphics Scripting – Scriptographer ported to JavaScript and the browser, using HTML5 Canvas. Created by @lehni & @puckey
http://paperjs.org
Other
14.45k stars 1.22k forks source link

Performance? #201

Closed JosefJezek closed 11 years ago

JosefJezek commented 11 years ago

http://jsperf.com/paper-vs-processing-vs-raphael/4

noisik commented 11 years ago

Also interested in this topic. Im new to paperjs, so i start testing the "Working with Mouse Vectors" paperscript on my iPhone and the first thing i noticed is how slow the performance is (delay on drag). There is a way for improve performance on mobile devices?

puckey commented 11 years ago

I do not see why you would remove and add the path each frame. The bonus of using Paper.js is that it has a DOM. @noisik there are indeed improvements to be made on the mobile side, do you have any advice for us?

lehni commented 11 years ago

I've been looking through this quite a bit. The comparison is interesting but not fair at all, for various reasons:

lehni commented 11 years ago

I have looked into this a bit further:

First I started by creating a preliminary Shape class, to see if that yields improvements. Weirdly enough, it was almost as slow. This means our actual Path / Segment code must perform well:

https://github.com/paperjs/paper.js/blob/master/src/item/Shape.js

Then I did some profiling, and found out that almost 1/4 of the time was spent in Style related code. So I reworked the Style related code to improve its performance, with notable results:

http://jsperf.com/paper-vs-processing-vs-raphael/8

On Safari, this test now runs notably faster than Raphael, but still slower than libraries that do not maintain a DOM. This is to be expected and no surprise at all, for all the reasons stated above.

I will close this issue now.

puckey commented 11 years ago

A more fitting way would be to create the rectangle in the initialization code and only call view.draw() every iteration. The rectangle does not need to be recreated each time: http://jsperf.com/paper-vs-processing-vs-raphael/12