NopCommerce v2.0 performance Profiling in VS 2010

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
i find some common performance issues after profiling the Performance .
1- Using .Any() instead of .Count >0  Link
2- Use IEnumerable insted of List or IList it has the same defirrent as of DataReader and the Data-set . Link
3- Using concurrentdictionary instead of Idictionary , it support using this scenario :
  if(conDictionary.TryGetValue("Key",out value)) // at this step the CLR will do one pass to check for the key and if it found it , will return true for the 'tryGetValue' method and will assign the value to the out parameter . so it is 50% faster , second it is a thread safe so there is no concurrent problems .
  
and i will try to find another point of enchantments for this great System .
12 years ago
Another Enhancement :
File "..\Libraries\Nop.Core\ComponentModel\GenericListTypeConverter.cs" line 64
old Code :
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                string result = string.Empty;
                if (((IList<T>)value) != null)
                {
                    //we don't use string.Join() because it doesn't support invariant culture
                  
                    for (int i = 0; i < ((IEnumerable<T>)value).Count; i++)
                    {
                        var str1 = Convert.ToString(((IEnumerable<T>)value)[i], CultureInfo.InvariantCulture);
                        result += str1;
                        //don't add comma after the last element
                        if (i != ((IEnumerable<T>)value).Count - 1)
                            result += ",";
                    }
                }
                return result;
            }

            return base.ConvertTo(context, culture, value, destinationType);
        }
New Code :
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                string result = string.Empty;
                if (((IEnumerable<T>)value) != null)
                {
                    //we don't use string.Join() because it doesn't support invariant culture
                    if (((IEnumerable<T>)value).Any())
                    {
                       return string.Join(",",((IEnumerable<T>) value).Select(row => Convert.ToString(row, CultureInfo.InvariantCulture)));

                    }
                  
                }
                return result;
            }

            return base.ConvertTo(context, culture, value, destinationType);
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.