4 Replies Latest reply on Nov 11, 2018 10:27 AM by Jagan

    AFAttributeList.GetValue() for 30 thousand attributes - How to make it faster?

    Jagan

      Hi!

       

      AFAttributeList attrList;
      // attrList = Around 30 thousand attributes are gathered into this from different elements. About 3% of total attributes are pointing to PI point
      AFValues afValues = attrList .GetValue()
      
      

       

      This GetValue() call is taking about 5 seconds to complete. Any comments on what can be done to reduce the time this takes?

       

      Following has been tried.

      attrList .GetValue()

      Takes about 5 seconds for the first time. If API is called again within few minutes then same will take about 2 seconds.

       

      Also tried Parallel like shown in below code, 30 thousand attributes are split into chunks of size 5000 and then performed GetValue(). This is still slow for the first time and takes about 4.5 seconds. About half a second improvement.

       

                 var values = new AFValues();
                  const int chunkSize = 5000;
                  List<AFAttribute> afAttributes = attributeList.ToList();
                  IEnumerable<List<AFAttribute>> result =ActionExtentions.SplitList(afAttributes, nSize: chunkSize);
                  List<AFAttributeList> listAFAttrList = result.Select(attributes => new AFAttributeList(attributes)).ToList();
                  Parallel.ForEach(listAFAttrList, afAttributeList =>
                  {
                      values.AddRange(afAttributeList.GetValue());
                  });