@clafarge
When we first added Javascript to Isadora, I ran a number of tests to determine the efficiency of the JS actor.
One of these tests was to recode the Smother actor in Javascript so that I had an identical process in JS. I then created Isadora patches with a thousand of the C++ version of smoother running, and the same for the JS version. What I saw was a very small increase in resources used for the JS processing. I continued to increase the number of actors and still saw only a slightly larger difference. Another test showed similar results for text formatting.
My takeaway was that the JS actor ran comparably fast, and wouldn't make any notable difference when used in most cases.
However, do remember you can create large loops in JS, which will take more cpu time, as well as operations like array sorting etc..
JS runs within the frameloop, and needs to return in a timely manner, it is Blocking, so if you run a long loop everything else in the patch has to wait for it to return.
TRY THIS
- Add a Shapes actor, connected to a projector and a Wave generator, so you see it moving in your stage preview
Try adding this code to a JS actor and change the input value:
function main()
{
for (let i = 0; i < 5000000; i++) {
print ("..." + i)
}
return arguments[0];
}
You will see output freezes while the JS actor counts to 1/2 million in the Monitor window.
Is it faster/slower to use JS to group a few functions together in a patch... I would say it is likely very close to the same cpu time (unless it's very complex)... does it save you the user time? probably if you are comfortable writing JS.