Пример #1
0
        public ContentionInfo GetContentionInfo(int threadId)
        {
            ContentionInfo contentionInfo;

            if (!_perThreadContentionInfo.TryGetValue(threadId, out contentionInfo))
            {
                contentionInfo = new ContentionInfo(_processId, threadId);
                _perThreadContentionInfo.Add(threadId, contentionInfo);
            }
            return(contentionInfo);
        }
Пример #2
0
        private void OnContentionStart(ContentionTraceData data)
        {
            ContentionInfo info = _contentionStore.GetContentionInfo(data.ProcessID, data.ThreadID);

            if (info == null)
            {
                return;
            }

            info.TimeStamp = data.TimeStamp;
            info.ContentionStartRelativeMSec = data.TimeStampRelativeMSec;
        }
Пример #3
0
        private void OnContentionStop(ContentionTraceData data)

        {
            ContentionInfo info = _contentionStore.GetContentionInfo(data.ProcessID, data.ThreadID);

            if (info == null)
            {
                return;
            }

            // unlucky case when we start to listen just after the ContentionStart event
            if (info.ContentionStartRelativeMSec == 0)
            {
                return;
            }

            var contentionDurationMSec = data.TimeStampRelativeMSec - info.ContentionStartRelativeMSec;

            info.ContentionStartRelativeMSec = 0;
            var isManaged = (data.ContentionFlags == ContentionFlags.Managed);

            NotifyContention(data.TimeStamp, data.ProcessID, data.ThreadID, TimeSpan.FromMilliseconds(contentionDurationMSec), isManaged);
        }