Optimising Quartz Composer Compositions

From QuartzCompositions.com the central source for Quartz Composer :: wiki

This page is intended for tips and tricks to optimize quartz compositions.

Table of contents

General Tips

  • Node Count : Try to use as few nodes as possible. Many patches can change the number of inputs they have, so instead of creating a "tree" of two-input patches, it is often preferrable to have one patch that has many inputs. If available, this selection will be in the second Inspector pane of the patch. These patches include Math, Logic, Conditional and Multiplexor.
  • Iterators : Try and limit the number of per iteration calculations you perform.

Core Image Tips

  • Pixel Count : The speed at which the Core Image filter(s) runs depends on how many pixels it has to operate on. Lower the number of pixels to increase the speed. By default the images being processed will be sized according to their size on screen. This is why a patch may run smoothly when small, but come to a crawl when expanded to full screen. In this case you should try and limit the number of pixels being processed. This can be done by scaling your images or explicitly setting image sizes. For example I typically set my Core Image Accumulator->Settings->Image Size to be 512x512.

NOTE : This technique is also useful if you want to fix the look of a Core Image Filter, which may change based on the resolution of the image which it is processing.

Core Image Kernel Tips

  • Sometimes it is faster to do things inside a core image kernel, and sometimes it is faster to use an Apple-supplied patch just before or after it. For example, some algorithms you might find in a textbook will include a gaussian blur. If the gaussian blur is already multiplied into a convolution kernel that you'll have to use anyway, it makes sense to leave it in. But if the gaussian blur expands the kernel to greater proportions, or causes an explosion in complexity that may make the kernel execute in the CPU instead of the GPU, putting a Gaussian Blur patch ahead of the kernel, outside the Core Image Kernel patch, may provide dramatic performance increase. For these things, it is often best to try them both ways.

Native/Cocoa/Carbon Tips

  • Converting an image to an NSImage effectively requires copying it out of VRAM into RAM, so can be an expensive operation, especially on machines with a low bus frequency (PowerPC laptops, etc.)