Grasshopper

algorithmic modeling for Rhino

Setting data hints on C# components makes calculation MUCH slower

Hi,

I recently noticed that, when creating a C# component, the performance can be greatly improved by NOT specifying the data types, and casting data types within the script itself. For example, to find the minimum value in a list called x:

    double minsofar = (double) x[0];
    foreach(object val in x)
{
minsofar = Math.Min((double) val, minsofar);
}

A = minsofar;

This would take 7ms to calculate on my computer for a list of 100000 numbers. But set the 'data hint' for x to 'double' (and ditch the casts within the code above) and the calculation time increases nearly 200x to 1.2 seconds!

I have written up in more detail about it here: 

http://james-ramsden.com/improve-grasshopper-component-performance-...

Any idea why this is happening? The difference is too great to ignore, especially for large canvases/data sets. While it's not much hassle to cast within the component, it makes the right-click menu redundant once you know this.

Views: 241

Attachments:

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service