[ANSWERED] JavaScript/[Actor] Benchmarking...
-
Is there a good way to benchmark efficiency, performance, and stability between different methods of doing a thing? I tend to lean toward JavaScript for many tasks. If a task is very simple/straightforward, I'll use other purpose-built Actors, but if I can reduce the number of Actors in use by having JavaScript do several of the steps a number of Actors would been used for, I happily take that path.
I'm interested in learning a good way to make sure that I'm choosing the correct path. Your benchmarking tools/methods would be helpful in this journey.
Thank you in advance.
Chad
-
@clafarge said:
Is there a good way to benchmark efficiency, performance, and stability between different methods of doing a thing?
If you want to compare two ways of doing a thing, the only way I can think of is to actually do it both ways then compare the results (looking at cycles per second and LOAD at bottom right).
My gut feeling is that replacing as many functions as possible with JS will generally be more efficient, but I could be wrong.
I'm interested to hear what others have to say on the topic.
Best wishes,
Woland
-
Thank you for the reply, and for moving this to a more appropriate place. I was thinking "Troubleshooting" as it's a cousin to benchmarking, but I agree: here is better.
As a developer, I sometimes set up scenarios where I'll monitor the execution time, CPU load, memory usage, etc., while I loop [doing a thing] 10k/50k times, and compare the results of different methods. I have tools like C#'s stopwatch for timing/duration and system performance/resource monitors that are accessible via code. I might even set up a session to continue for hours and see if I can melt a server. I haven't been as adventurous in Isadora, as yet.
I was hoping there were some known best-practices to draw from that address Isadora specifically, as it sort of operates differently from my normal environment.
Best,
Chad
-
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.
-
That's a great help, thank you!