/// <summary> /// Event filtering by process ID. Called in ForwardEventEnumerator::MoveNext /// </summary> /// <param name="data"></param> /// <returns></returns> bool FilterEvent(TraceEvent data) { if (data.ProcessID == m_procID) { if (m_gcProcess == null) { m_gcProcess = m_processLookup[data]; } if (m_source == null) { m_source = data.Source; FirstEventTime = data.TimeStampRelativeMSec; } LastEventTime = data.TimeStampRelativeMSec; if (data.ProviderGuid == kernelGuid) { } return(true); } return(false); }
/// <summary> /// Creates a session if it does not exist and increments the reference count on the session. /// </summary> /// <param name="beginEvent">Unused.</param> public override void BeginIteration(TraceEvent beginEvent) { if (s_session == null) { // The filter function here is to filter out events that we are not concerned with collecting, i.e. events from // processes not spawned by us. s_session = GCProcess.Collect(_context.TraceEventSource as TraceEventDispatcher, SampleRate, filterFunc: _context.IsTestEvent); s_hasComputedRollup = false; } s_sessionRefCount++; }
public bool LoadEvents(int procID, int sampleInterval100ns) { m_procID = procID; m_SampleInterval = sampleInterval100ns / 10000.0; // Filter to process TraceEvents processEvents = m_traceLog.Events.Filter(FilterEvent); // Get Dispatcher TraceEventDispatcher source = processEvents.GetSource(); kernelGuid = KernelTraceEventParser.ProviderGuid; // Hookup events source.Clr.All += OnClrEvent; ClrPrivateTraceEventParser clrPrivate = new ClrPrivateTraceEventParser(source); clrPrivate.All += OnClrPrivateEvent; KernelTraceEventParser kernel = source.Kernel; kernel.PerfInfoSample += delegate(SampledProfileTraceData data) { ThreadMemoryInfo thread = GetThread(data.ThreadID); thread.AddEvent(HeapEvents.CPUSample, data.TimeStampRelativeMSec); }; kernel.VirtualMemAlloc += OnVirtualMem; kernel.VirtualMemFree += OnVirtualMem; m_processLookup = new ProcessLookup <GCProcess>(); // Process all events into GCProcess lookup dictionary GCProcess.Collect(source, sampleInterval100ns, m_processLookup, null, false, m_traceLog); // Get the process we want return(m_processLookup.TryGetByID(procID, out m_gcProcess)); }