Beispiel #1
0
 /// <summary>
 /// 移出一个观察
 /// </summary>
 /// <param name="entity"></param>
 protected virtual void RemoveWatch(RecordWatchEntity entity)
 {
     if (entity == null || string.IsNullOrEmpty(entity.WatchKey))
     {
         return;
     }
     RemoveWatch(entity.WatchKey);
 }
Beispiel #2
0
 /// <summary>
 /// 增加一个观察
 /// </summary>
 /// <param name="entity"></param>
 protected virtual void AddWatch(RecordWatchEntity entity)
 {
     if (entity == null || string.IsNullOrEmpty(entity.WatchKey)) return;
     if (_recordEnitys.ContainsKey(entity.WatchKey))
         _recordEnitys[entity.WatchKey] = entity;
     else
         _recordEnitys.Add(entity.WatchKey, entity);
     CurrentWatch = entity;
 }
Beispiel #3
0
        /// <summary>
        /// 清理观察
        /// </summary>
        public void ClearWatch()
        {
            RecordWatchEntity entity = CurrentWatch;

            if (entity == null)
            {
                return;
            }
            RemoveWatch(entity);
        }
Beispiel #4
0
 /// <summary>
 /// 开始观察
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public void StartWatch(string key)
 {
     RecordWatchEntity entity = CurrentWatch;
     if (entity != null && entity.IsWatch)
     {
         LCSConsole.WriteError("已经开始观察性能......");
         return;
     }
     if (entity == null) entity = new RecordWatchEntity { WatchKey = string.IsNullOrEmpty(key) ? LCSGuid.NewUpperGuid() : key };
     entity.BeginWatch();
     AddWatch(entity);
 }
Beispiel #5
0
        /// <summary>
        /// 结束观察
        /// </summary>
        /// <returns></returns>
        public double EndWatch()
        {
            RecordWatchEntity entity = CurrentWatch;

            if (entity == null)
            {
                LCSConsole.WriteError("观察还未开始...");
                return(0);
            }
            entity.IsWatch = false;
            entity.EndTime = Time.realtimeSinceStartup;
            LCSConsole.Write(string.Format(" [RecordTime] {0} use {1}s.", entity.WatchKey, entity.DiffTime));
            return(entity.DiffTime);
        }
Beispiel #6
0
        /// <summary>
        /// 得到观察的时间
        /// </summary>
        /// <returns></returns>
        public double GetWatchTime()
        {
            RecordWatchEntity entity = CurrentWatch;

            if (entity == null)
            {
                LCSConsole.WriteError("观察还未开始...");
                return(0);
            }
            if (entity.IsWatch)
            {
                LCSConsole.WriteError("观察还未结束...");
                return(0);
            }
            return(entity.DiffTime);
        }
Beispiel #7
0
 /// <summary>
 /// 增加一个观察
 /// </summary>
 /// <param name="entity"></param>
 protected virtual void AddWatch(RecordWatchEntity entity)
 {
     if (entity == null || string.IsNullOrEmpty(entity.WatchKey))
     {
         return;
     }
     if (_recordEnitys.ContainsKey(entity.WatchKey))
     {
         _recordEnitys[entity.WatchKey] = entity;
     }
     else
     {
         _recordEnitys.Add(entity.WatchKey, entity);
     }
     CurrentWatch = entity;
 }
Beispiel #8
0
        /// <summary>
        /// 结束观察
        /// </summary>
        public double EndWatch()
        {
            RecordWatchEntity entity = CurrentWatch;

            if (entity == null)
            {
                LCSConsole.WriteError("观察还未开始...");
                return(0);
            }
            entity.EndWatch();
            double watchTime = entity.GetWatchTime();

            // 7位精度
            LCSConsole.WriteWarning("[Watch] {0} use time : {1}s.", entity.WatchKey, watchTime.ToString("F7"));
            return(watchTime);
        }
Beispiel #9
0
        /// <summary>
        /// 开始观察
        /// </summary>
        /// <param name="key">指定key值</param>
        public void StartWatch(string key)
        {
            RecordWatchEntity entity = CurrentWatch;
            if (entity != null && entity.IsWatch)
            {
                LCSConsole.WriteError("已经开始观察性能......");
                return;
            }

            if (entity == null) entity = new RecordWatchEntity { WatchKey = string.IsNullOrEmpty(key) ? LCSGuid.NewUpperGuid() : key };
            entity.IsWatch = true;
            entity.StartTime = Time.realtimeSinceStartup;

            // 记录 自游戏开始的实时时间
            AddWatch(entity);
        }
Beispiel #10
0
        /// <summary>
        /// 开始观察
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public void StartWatch(string key)
        {
            RecordWatchEntity entity = CurrentWatch;

            if (entity != null && entity.IsWatch)
            {
                LCSConsole.WriteError("已经开始观察性能......");
                return;
            }
            if (entity == null)
            {
                entity = new RecordWatchEntity {
                    WatchKey = string.IsNullOrEmpty(key) ? LCSGuid.NewUpperGuid() : key
                }
            }
            ;
            entity.BeginWatch();
            AddWatch(entity);
        }
Beispiel #11
0
        /// <summary>
        /// 开始观察
        /// </summary>
        /// <param name="key">指定key值</param>
        public void StartWatch(string key)
        {
            RecordWatchEntity entity = CurrentWatch;

            if (entity != null && entity.IsWatch)
            {
                LCSConsole.WriteError("已经开始观察性能......");
                return;
            }

            if (entity == null)
            {
                entity = new RecordWatchEntity {
                    WatchKey = string.IsNullOrEmpty(key) ? LCSGuid.NewUpperGuid() : key
                }
            }
            ;
            entity.IsWatch   = true;
            entity.StartTime = Time.realtimeSinceStartup;

            // 记录 自游戏开始的实时时间
            AddWatch(entity);
        }
Beispiel #12
0
 /// <summary>
 /// 移出一个观察
 /// </summary>
 /// <param name="entity"></param>
 protected virtual void RemoveWatch(RecordWatchEntity entity)
 {
     if (entity == null || string.IsNullOrEmpty(entity.WatchKey)) return;
     RemoveWatch(entity.WatchKey);
 }