1. sanping peng
  2. .NET DataStore
  3. Wednesday, 26 January 2022 00:40 AM UTC

GetModel<appfunc>(i,false) //24962 rows

vs

GetMode<appfunc>(i,true) //24962 rows

Six simple compute column make get model,time from 64ms to 1755ms(27 times),memory from 10M to 137M(13.7 times)?

Why?

Test again:

Core code:

public object FxDataStore2Model(int concurrent)
        {
            try
            {
                for (int i = 0; i < concurrent; i++)
                {
                    List<appfunc> lst = new List<appfunc>();
                    for (int j = 0; j < FxDataInDataStore.RowCount; j++)
                    {
                        lst.Add(FxDataInDataStore.GetModel<appfunc>(j, true));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return 0;
        }

public object FxDataStore2ModelSimple(int concurrent)
        {
            try
            {
                for (int i = 0; i < concurrent; i++)
                {
                    List<appfunc> lst = new List<appfunc>();
                    for (int j = 0; j < FxDataInDataStore.RowCount; j++)
                    {
                        lst.Add(FxDataInDataStore.GetModel<appfunc>(j, false));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return 0;
        }



using DWNet.Data;
using SnapObjects.Data;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
using System.Text;
namespace FxPerformanceTest
{
	[DataWindow("appfunc", DwStyle.Default)]
    [FromTable("AppFunc", Schema = "fxprj00auth")]

    #region DwSelectAttribute  
    [DwSelect(@"  SELECT  fxprj00auth.AppFunc.FuncID,              fxprj00auth.AppFunc.FuncName,              fxprj00auth.AppFunc.FuncTitle,              fxprj00auth.AppFunc.FuncType,              fxprj00auth.AppFunc.ParamNameValue,              fxprj00auth.AppFunc.RelatedFuncID,              fxprj00auth.AppFunc.Disabled,              fxprj00auth.AppFunc.FlagDelete,              fxprj00auth.AppFunc.SortID,              fxprj00auth.AppFunc.Memo,              fxprj00auth.AppFunc.ParentID,              fxprj00auth.AppFunc.CreateDate,              fxprj00auth.AppFunc.CreateUserID,              fxprj00auth.AppFunc.UpdateDate,              fxprj00auth.AppFunc.UpdateUserID,    (CASE WHEN IsNull(fxprj00auth.AppFunc.ParentID,'0')='0' THEN fxprj00auth.AppFunc.FuncID ELSE fxprj00auth.AppFunc.ParentID+'__'+  fxprj00auth.AppFunc.FuncID  END)  AS SortInfo      FROM fxprj00auth.AppFunc     WHERE ('xxxxxx'='xxxxxx')  ORDER BY (CASE WHEN IsNull(fxprj00auth.AppFunc.ParentID,'0')='0' THEN fxprj00auth.AppFunc.FuncID ELSE fxprj00auth.AppFunc.ParentID+'__'+  fxprj00auth.AppFunc.FuncID  END) ,SortID")]
    #endregion
  
    [UpdateWhereStrategy(UpdateWhereStrategy.KeyColumns)]

    [DwKeyModificationStrategy(UpdateSqlStrategy.Update)]
    public class appfunc
    {
        //-----------------------------------------
		//columns
        [Key]
        [DwColumn("AppFunc", "FuncID")]
		public string funcid{get;set;}

        [DwColumn("AppFunc", "FuncName")]
		public string funcname{get;set;}

        [DwColumn("AppFunc", "FuncTitle")]
		public string functitle{get;set;}

        [DwColumn("AppFunc", "FuncType")]
		public string functype{get;set;}

        [DwColumn("AppFunc", "ParamNameValue")]
		public string paramnamevalue{get;set;}

        [DwColumn("AppFunc", "RelatedFuncID")]
		public string relatedfuncid{get;set;}
        
        [DwColumn("AppFunc", "Disabled")]
		public int? disabled{get;set;}
        
        [DwColumn("AppFunc", "FlagDelete")]
		public int? flagdelete{get;set;}

        [DwColumn("AppFunc", "SortID")]
		public int? sortid{get;set;}

        [DwColumn("AppFunc", "Memo")]
		public string memo{get;set;}

        [DwColumn("AppFunc", "ParentID")]
		public string parentid{get;set;}

        [DwColumn("AppFunc", "CreateDate")]
		public DateTime? createdate{get;set;}

        [DwColumn("AppFunc", "CreateUserID")]
		public string createuserid{get;set;}

        [DwColumn("AppFunc", "UpdateDate")]
		public DateTime? updatedate{get;set;}

        [DwColumn("AppFunc", "UpdateUserID")]
		public string updateuserid{get;set;}

        [PropertySave(SaveStrategy.Ignore)]
        [DwColumn("SortInfo")]
		public string sortinfo{get;set;}

        //-----------------------------------------
        //computes
        [DwCompute(@"disabled+1+flagdelete+1+sortid+1")]
        public int? total { get; set; }
        [DwCompute(@"disabled+1+flagdelete+1+sortid+1")]
        public int? total1 { get; set; }
        [DwCompute(@"disabled+1+flagdelete+1+sortid+1")]
        public int? total2 { get; set; }
        [DwCompute(@"disabled+1+flagdelete+1+sortid+1")]
        public int? total3 { get; set; }
        [DwCompute(@"disabled+1+flagdelete+1+sortid+1")]
        public int? total4 { get; set; }
        [DwCompute(@"disabled+1+flagdelete+1+sortid+1")]
        public int? total5 { get; set; }
        
        
    }
    public static class appfunc__extensions
    {
        public static object?[] Model2Buffer(this appfunc obj)
        {
            List<object> buffer = new List<object>();
            buffer.Add(obj.funcid);
            buffer.Add(obj.funcname);
            buffer.Add(obj.functitle);
            buffer.Add(obj.functype);
            buffer.Add(obj.paramnamevalue);
            buffer.Add(obj.relatedfuncid);
            buffer.Add(obj.disabled);
            buffer.Add(obj.flagdelete);
            buffer.Add(obj.sortid);
            buffer.Add(obj.memo);
            buffer.Add(obj.parentid);
            buffer.Add(obj.createdate);
            buffer.Add(obj.createuserid);
            buffer.Add(obj.updatedate);
            buffer.Add(obj.updateuserid);
            buffer.Add(obj.sortinfo);
            buffer.Add(obj.total);
            buffer.Add(obj.total1);
            buffer.Add(obj.total2);
            buffer.Add(obj.total3);
            buffer.Add(obj.total4);
            buffer.Add(obj.total5);
            return buffer.ToArray();
        }
        public static TModel Buffer2Model<TModel>(this DataRow dataRow) where TModel : appfunc
        {
            object?[] buffer = dataRow.ItemArray;
            appfunc obj = new appfunc();
            obj.funcid = buffer[0] as string;
            obj.funcname = buffer[1] as string;
            obj.functitle = buffer[2] as string;
            obj.functype = buffer[3] as string;
            obj.paramnamevalue = buffer[4] as string;
            obj.relatedfuncid = buffer[5] as string;
            obj.disabled = buffer[6] as int?;
            obj.flagdelete = buffer[7] as int?;
            obj.sortid = buffer[8] as int?;
            obj.memo = buffer[9] as string;
            obj.parentid = buffer[10] as string;
            obj.createdate = buffer[11] as DateTime?;
            obj.createuserid = buffer[12] as string;
            obj.updatedate = buffer[13] as DateTime?;
            obj.updateuserid = buffer[14] as string;
            obj.sortinfo = buffer[15] as string;
            obj.total = buffer[16] as int?;
            obj.total1 = buffer[17] as int?;
            obj.total2 = buffer[18] as int?;
            obj.total3 = buffer[19] as int?;
            obj.total4 = buffer[20] as int?;
            obj.total5 = buffer[21] as int?;
            return obj as TModel;
        }
    }

}

 

Logan Liu @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 26 January 2022 12:30 PM UTC
  2. .NET DataStore
  3. # 1

Hi Sanping,

Thank you for pointing out this PB expression performance issue of the DwCompute attribute.

Please open a ticket through our support portal at https://www.appeon.com/standardsupport/newbug.

Regards,

Logan

Comment
  1. sanping peng
  2. Wednesday, 26 January 2022 12:56 PM UTC
thanks for your reply,bug reported.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.