How to find performance bottleneck with profiler widget?

It’s been wished for before, but once solutions are cancellable and background threaded that no longer matters. It’s okay for Grasshopper to begin a super long loop as long as it’s possible for you to terminate it by making a change to the document. The only problem is excessive memory consumption, but even that is unlikely to cause a shutdown on 64-bit systems.

1 Like

Have a look at the Make2D RhinoCommon implementation.

The last argument in the method is a CancellationToken, which is the standard .NET method for aborting long running processes. What you do is create a new CancellationtokenSource instance, then pass its tokens out to however many processes you’re running. You can then cancel them all by calling one of the Cancel() methods on the source.

The Make2D method also provides a progress feedback method, so you can keep track of how far along it is while it’s running.

2 Likes

Hi, now I have a follow-up question. How would I go about checking for performance bottlenecks/errors when the profiler wont show any irregularities but my script still takes 10 mins to start up?

I´m using mainly Ladybug tools and some Human/metahopper components. Does the profiler widget work with all components written in python like LBtools? Which calculations does it not time? (I have suspisions that its the Human block handling components that drag me down, but cant pinpoint it nonetheless)

Lots. It only measures operations that are part of data collection and computing. For standard components this most significantly omits the time needed to compute preview meshes (which can be a long time if you’re unlucky), however for non-standard components there could be all sorts of things happening that aren’t timed.

If you start GH anew and just create a new file by dragging a single component onto the canvas, does it also take a long time?

@TomTom,
Thanks for the code. I’m trying to use it but when the runtime is higher than miliseconds the output is not correct. I’m running cases where running time can be in seconds, minutes or even hours.
Tried to change the code but with no success.
Can you give pointers to change the code?
Thanks (and hope this thread is not too old),
-A.