/// <summary> /// Create a new frame out of 'nothing' (just its name) and optionaly a module /// </summary> public StackSourceFrameIndex GetFrameIndexForName(string frameName, StackSourceModuleIndex moduleIdx = StackSourceModuleIndex.Invalid) { if (moduleIdx == StackSourceModuleIndex.Invalid) { moduleIdx = m_emptyModuleIdx; } return(m_Interner.FrameIntern(frameName, moduleIdx)); }
public MyStackSource() { StackSourceModuleIndex emptyModuleIdx = Interner.ModuleIntern(""); // Make up a stack source with 10 samples in it, all with the same stack. var mySample = new StackSourceSample(this); for (int i = 0; i < 10; i++) { mySample.TimeRelativeMSec = i; mySample.Metric = 10 + i; // Just to make things interesting. mySample.StackIndex = StackSourceCallStackIndex.Invalid; // Add a frame 'Frame 1' mySample.StackIndex = Interner.CallStackIntern(Interner.FrameIntern("Frame 1", emptyModuleIdx), mySample.StackIndex); // Add a frame 'Frame 2' mySample.StackIndex = Interner.CallStackIntern(Interner.FrameIntern("Frame 2", emptyModuleIdx), mySample.StackIndex); // This copies mySample, so you can keep reusing mySample for the next sample AddSample(mySample); } }
public void OpenWcfEventsView(string etlFileName, string viewName) { ETLDataFile etlFile = OpenETLFile(etlFileName); TraceLog traceLog = etlFile.TraceLog; var eventSource = traceLog.Events.GetSource(); var stackSource = new InternStackSource(); StackSourceModuleIndex emptyModuleIdx = stackSource.Interner.ModuleIntern(""); var mySample = new StackSourceSample(stackSource); var operations = new List <OperationData>(); var opStartTimeStamps = new Dictionary <int, double>(); var pendingOps = new Dictionary <int, OperationData>(); eventSource.Dynamic.All += x => OnNewEvent(operations, opStartTimeStamps, pendingOps, x); eventSource.Process(); foreach (var op in operations) { mySample.TimeRelativeMSec = op.TimeStamp; mySample.Metric = (float)op.Duration.TotalMilliseconds; mySample.StackIndex = stackSource.Interner.CallStackIntern( stackSource.Interner.FrameIntern(op.Contract, emptyModuleIdx), StackSourceCallStackIndex.Invalid); mySample.StackIndex = stackSource.Interner.CallStackIntern( stackSource.Interner.FrameIntern(op.Name, emptyModuleIdx), mySample.StackIndex); stackSource.AddSample(mySample); } Stacks stacksForViewer = new Stacks(stackSource, viewName, etlFile); OpenStackViewer(stacksForViewer); }