c# - Performance issues in processing loop -


while iterating through dataset of 3000 float values , running inner loop, code runs through first 10% in seconds takes 20 minutes complete last 90%. number of new objects created has been reduced as practical.

calling gc.collect(); gc.waitforpendingfinalizers(); @ fixed intervals in outer loop resulted in no change.

how can fast performance maintained through entire loop? actual class used instead of object.

public method:

    public static float [] compute             ( ref float [] sourcedata , ref object [] referencedata,               ref float [] progress )     {          int count = 0;         float [] result = new float [sourcedata.length];         float inverselength = 1f / ((float) sourcedata.length);          ( int = 0; < sourcedata.length; i++ )         {              progress [0] = ( (float) ) * inverselength ;             result[i] = computedatum (ref sourcedata [i], ref referencedata);              if (count++ == 100)             {                 count = 0;                 gc.collect ( );                 gc.waitforpendingfinalizers ( );             }         }          return result;      } 

inner loop in private method:

    private static float computedatum              ( ref float sourcedatum , ref object [] referencedata)     {          object workingobject = new object();         float result = 0f;          foreach ( object o in referencedata )         {             workingobject = new object(o);             //...perform transformation operations on workingobject...             //...store results of computation result...         }          return result;      } 


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -