Exemplo n.º 1
0
    public static void StartRecord(string timerId, int type)
    {
        if (!_isStart)
        {
            return;
        }
        if (_timerStartIdRecords.Contains(timerId))
        {
            CatDebug.CWarning("StartRecord :Repeat timerID = " + timerId, CatLogType.CatTimer);
            return;
        }

        if (string.IsNullOrEmpty(timerId))
        {
            CatDebug.CError("StartRecord : Null/Empty timerID.", CatLogType.CatTimer);
            return;
        }

        if (_isShowDetail)
        {
            CatDebug.CLog("StartRecord : " + timerId + "," + type, CatLogType.CatTimer);
        }

        _lastLineTimerId   = timerId;
        _lastLineTimerType = type;

        _timerStartIdRecords.Add(timerId);
        _timerStartTimeRecords.Add(DateTime.Now);
    }
Exemplo n.º 2
0
    public static void EndRecord(string timerId)
    {
        if (!_isStart)
        {
            return;
        }
        int index = _timerStartIdRecords.IndexOf(timerId);

        if (index < 0)
        {
            CatDebug.CError("EndRecord : Null timerID = " + timerId, CatLogType.CatTimer);
            return;
        }
        TimeSpan ts = DateTime.Now - _timerStartTimeRecords[index];

        _timerStartIdRecords.RemoveAt(index);
        _timerStartTimeRecords.RemoveAt(index);
        if (_isShowDetail)
        {
            CatDebug.CLog("EndRecord : " + timerId + " Cost " + ts.TotalSeconds, CatLogType.CatTimer);
        }
        //_timerEndRecords.Add(timerId, ts.TotalMilliseconds);
        AddEndRecord(timerId, ts.TotalSeconds);
        if (timerId.Equals(_lastLineTimerId))
        {
            _lastLineTimerId = string.Empty;
        }
    }