示例#1
0
 public CodeStatistics(int code, string name = null)
 {
     Code = code;
     if (name == null)
     {
         name = code.ToString();
     }
     mLastTime       = BeetleX.TimeWatch.GetTotalSeconds();
     Name            = name;
     mStatisticsData = new CodeStatisticsData();
 }
示例#2
0
        public CodeStatisticsData GetData()
        {
            if (TimeWatch.GetTotalSeconds() - mLastTime > 1)
            {
                if (System.Threading.Interlocked.CompareExchange(ref mGetStatus, 1, 0) == 0)
                {
                    CodeStatisticsData result = mStatisticsData;
                    result.CreateTime = TimeWatch.GetTotalSeconds();
                    result.Count      = Count;
                    double now  = TimeWatch.GetTotalSeconds();
                    double time = now - mLastTime;
                    result.Increase = (double)(mCount - mLastCount);
                    result.Rps      = (int)((result.Increase) / time);

                    mLastTime  = now;
                    mLastCount = mCount;
                    mGetStatus = 0;
                }
            }
            return(mStatisticsData);
        }