Grasshopper

algorithmic modeling for Rhino

I am trying to translate a short python script in C# for speed purposes but I guess my C# skills are not to par compared to my python.

The script takes a point and associated values and follows the highest values (for a certain depth), all according to a topology map/

I don't understand why the custom method does not recognize some of my gh inputs. (guess it is a C# thing and I have to pass them in the fuction)

Eventually the idea is to output real-time and multithreaded but I'm trying to take it one step at a time.

Views: 614

Attachments:

Replies to This Discussion

gone in 1ms (the thing not the corrections, he he)

Attachments:

sweet mother of speed...

V2 (the trad update) it would be way faster

i feel like a caveman with my python.... do you have a multithreaded solution?

Hi Dimitar, I just tried out the tips I posted here on your GHPython component. It severely speeds up the calculation, by about an order of 50!! Note that I did not open/read/alter your script, this is just from not setting Type Hints on your list/datatree parameter inputs. You could probably make a slightly faster by moving it over to C#, but I doubt that it would be worth it to implement multithreading for this task (if about 5 ms is fast enough, that is).. 

Attachments:

yea I was thinking one step ahead. This script should run over each point in the list not only for a single item.(that is where I was considering multithreading)

Sometimes it's better to think one step backwards though ;) I think you might have missed my point. By profiling your code/examining your component more closely you might be able to identify bottlenecks (in this case, the cost of casting to types that occurs when you set a type hint on the GHPython component). This finding made the computation 50 times faster in the definition I posted above, with no change to the script itself! The best you would get with multi-threading would be "amount of cores" faster (although that is rarely the case in my experience with multi-threading).

Weird, on my system your definition is consistently slower than Dimitar's original script: 

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service