Quartz Composer Math vs Expression vs JavaScript performance comparison (2008)

I’ve always wondered (well at least since Quartz Composer 3.0 was released with Leopard) the performance difference between using the new and much easier to use Math Expression patch, and the old Math patch – and in fact compared to using JavaScript.

So I created the attached test composition and found some surprising results (at least I found them surprising, though in retrospect I can understand why :P).

First of all, all 3 methods are pretty quick, and are unlikely to be a bottleneck. Unless you are using the operations in anIterator patch with a lot of iterations you won’t notice any difference.

The figures below are for 2nd gen 2.33Ghz Macbook Pro:

iterations
Math
Math Expression
JavaScript
comments
100
246 fps
255 fps
165 fps
performance difference is quite negligable!
400
83 fps
93 fps
57 fps
starting to get a bit more important
1600
29 fps
33 fps
18 fps
with vsync on, Math vs Expr can make the difference between 20 vs 30 fps!
3600
14.5 fps
16 fps
8.3 fps
with vsync on, 10 vs 15fps

The Math Expression patch is slightly faster than the Math patch (fps improves around 10-13%)… which is good news because I think its way easier and tidier to use! (Just look inside the associated iterator patches in the attached composition to see!!). And the JavaScript patch is considerably slower than the other two (fps is almost half that of the Math Expression patch).

Of course this isn’t the most scientific test. I’m sure the bottleneck in this composition is not the difference between the patches, but probably rendering and/or the overheads of the Iterator patch (it seems quite slow at high iteration counts anyway) – but the results are still quite clear. Its hard to deduce exactly how much faster Math Expression is compared to the Math patch, but frankly I don’t really care. All I wanted to see was whether the Math Expression patch was slower than the Math patch or not, and it clearly isn’t!

If you want to see the tests for yourself (or want to see some trippy flashing squares) you can run the attached composition, but first you need to disable syncing to the vertical blank interval. You do this by (do this all in QC) :

  1. Click on the Quartz Composer menu (top left)
  2. hold down the option key and choose preferences (this will show the private preferences)
  3. in the (editor) tab tick disableVBLSyncing
  4. restart Quartz Composer

Make sure you un-tick the option (and re-enable VBLsyncing) after you’re done if you don’t want any tearing artifacts.
P.S. Thanks to Vade for pointing out the tip with the private preferences!

Math vs Expression vs JavaScript.qtz

I’ve always wondered (well at least since Quartz Composer 3.0 was released with Leopard) the performance difference between using the […]

Related keywords

open source, quartz composer, tutorial