Thanks Jonathan
Every time I write a line of code in JS I'm wondering 'is this method
faster than some other way' (hand coding in a loop instead of .slice
or whatever). I never stop wondering about those things. Sending
calculations to functions instead of inline, nested functions instead of
I think I find C syntax more direct than JS (novice-intermediate at
both). It's high time I learned enough Cocoa to wrap some C code into
a plugin to do these kind of number crunching things. Or got new metal
to run OpenCL which sounds kinda risky itself.
Thanks for tip of typeof statement. What's risky about nested loops?
Risky as in potentially slow? Are for (k in me) {} loops any slower
than for (i=0; i<length; i++) {} loops for example?
Best
Alastair
The machine does not isolate man from the great problems of nature but
plunges him more deeply into them.
Antoine de Saint-Exupery
On 01/03/2011, at 7:24 PM, Jonathan Hart wrote:
I'm not a guru on JS performance in QC, but here's my 2 cents...
Your first Javascript patch you're doing a lot of risky stuff such
as typeof and nested for loops.
Your second JS patch is doing more risky stuff.. like array slicing.
These can be notoriously slow operations depending on the JIT being
used.
Keep in mind interpreted languages such as Javascript are at the
mercy of their JIT compilers and each one has its performance quirks
when handling things like loops and especially untyped operations
(like typeof and untyped array operations like slice).
You are also inputting and outputting entire structures, which may
be slow even with smaller lengths, depending on how QC passes these
things in and out of the JS.
One of the downsides to untyped languages like JS. You trade off
performance for easy syntax.
Jonathan
On Tue, Mar 1, 2011 at 12:15 AM, Alastair Leith <qc.student...@gmail.com
> wrote:
Hi Christopher,
This example I have two JS patches. The first just flip-flops b/w
two Arrays of n and n/2 elements. It only takes CPU when changing
state.
The second patch modifies it's output to match the length of the
input Array. First it compares .length of the Arrays, if same do
nothing.
Although it's actually written if (a<b) {lose elements}; if (a>b)
{add elements}, where a is input and b is internal JS array.
So maybe some kind of if (a == b) break_statement(?); is required
Anyhow without a Time input forcing execution every frame it runs
60fps even on my old box but with execution every frame it crawls to
5fps at n=2000
Best
Alastair
The machine does not isolate man from the great problems of nature
but plunges him more deeply into them.
Antoine de Saint-Exupery
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list (Quartzcomposer-dev@lists.apple.com
)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/jonathan.hart%40gmail.com
This email sent to jonathan.h...@gmail.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list (Quartzcomposer-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com