/// <summary> /// Invoked when an analysis needs to be performed. /// </summary> protected override EventOutput OnAnalyze() { // Here we will store our results var output = new EventOutput(this.Process.Name); // Process every frame foreach (var frame in this.Frames) { // Build some shortcuts var core = frame.Core; // Get corresponding hardware counters var cn = frame.HwCounters; /*var contextSwitches = this.TraceLog.Events * .Where(e => e.EventName == "Thread/CSwitch") * .Where(e => e.ProcessorNumber == core) * .Where(e => e.ProcessID == this.Process.ProcessID) * .Where(e => e.TimeStamp >= frame.Time) * .Where(e => e.TimeStamp <= frame.Time + frame.Duration) * .Count(); * * output.Add("switch", frame, EventThread.Custom, contextSwitches);*/ // Process every thread within this frame foreach (var thread in frame.Threads) { // Get the number of cycles elapsed var multiplier = frame.GetOnCoreRatio(thread); var cycles = Math.Round(multiplier * cn.Cycles); output.Add("cycles", frame, thread, cycles); // Time in milliseconds output.Add("ready", frame, thread, frame.GetTime(thread, ThreadState.Ready) / 10000); output.Add("running", frame, thread, frame.GetTime(thread, ThreadState.Running) / 10000); output.Add("standby", frame, thread, frame.GetTime(thread, ThreadState.Standby) / 10000); output.Add("wait", frame, thread, frame.GetTime(thread, ThreadState.Wait) / 10000); } } // Return the results return(output); }
/// <summary> /// Invoked when an analysis needs to be performed. /// </summary> protected override EventOutput OnAnalyze() { // Here we will store our results var output = new EventOutput(this.Process.Name); var processes = this.TraceLog.Processes .Select(p => new { Name = p.Name, Id = p.ProcessID }) .ToArray(); // Get the context switches var contextSwitches = this.Switches .Where(e => e.TimeStamp >= this.Start) .Where(e => e.TimeStamp <= this.End) .ToArray(); foreach (var sw in contextSwitches) { var program = processes .Where(p => p.Id == sw.NewProcessId) .First(); output.Add("sw", program.Name, "", sw.TimeStamp, 1, sw.NewThreadId, sw.NewProcessId, sw.ProcessorNumber, 0); } // Only export relevant processes var lifetimes = this.Lifetimes .Where(e => e.ProcessId == this.Process.ProcessID); foreach (var lt in lifetimes) { output.Add(lt.State.ToString().ToLowerInvariant(), this.Process.Name, "", lt.TimeStamp, 1, lt.ThreadId, lt.ProcessId, lt.ProcessorNumber, 0); } // Return the results return(output); }
/// <summary> /// Invoked when an analysis needs to be performed. /// </summary> protected override EventOutput OnAnalyze() { // Here we will store our results var output = new EventOutput(this.Process.Name); // This is for mapping pointers to a lock number var locks = new Dictionary <long, int>(); var locki = 0; // Export every event foreach (var ev in this.LockAcquisitions) { if (!locks.ContainsKey(ev.Lock)) { locks[ev.Lock] = ++locki; } output.Add(ev.Type.ToString().ToLowerInvariant(), this.Process.Name, "", ev.TimeStamp, locks[ev.Lock], ev.ThreadId, ev.ProcessId, ev.ProcessorNumber, 0); } // Return the results return(output); }
/// <summary> /// Invoked when an analysis needs to be performed. /// </summary> protected override EventOutput OnAnalyze() { // Here we will store our results var output = new EventOutput(this.Process.Name); // Process every frame foreach (var frame in this.Frames) { // Build some shortcuts var core = frame.Core; // Get corresponding hardware counters var cn = frame.HwCounters; // Process every thread within this frame foreach (var thread in frame.Threads) { // Get the multiplier for that thread var multiplier = frame.GetOnCoreRatio(thread); // Get the number of demand zero faults. var dzf = frame.PageFaults .Where(pf => pf.Type == PageFaultType.Minor) .Where(pf => pf.Thread == thread.Tid && pf.Process == thread.Pid) .Count(); // Get the number of har" page faults. var hpf = frame.PageFaults .Where(pf => pf.Type == PageFaultType.Major) .Where(pf => pf.Thread == thread.Tid && pf.Process == thread.Pid) .Count(); // Get the number of cycles elapsed var cycles = Math.Round(multiplier * cn.Cycles); output.Add("cycles", frame, thread, cycles); output.Add("time", frame, thread, multiplier); output.Add("l1miss", frame, thread, Math.Round(multiplier * cn.L1Misses)); output.Add("l2miss", frame, thread, Math.Round(multiplier * cn.L2Misses)); output.Add("l3miss", frame, thread, Math.Round(multiplier * cn.L3Misses)); output.Add("tlbmiss", frame, thread, Math.Round(multiplier * cn.TLBMisses)); output.Add("dzf", frame, thread, dzf); output.Add("hpf", frame, thread, hpf); output.Add("ipc", frame, thread, cn.IPC); output.Add("tlbperf", frame, thread, cn.TLBClock); output.Add("l1perf", frame, thread, (multiplier * cn.L2Hits * 10) / cycles); output.Add("l2perf", frame, thread, cn.L2Clock); output.Add("l3perf", frame, thread, cn.L3Clock); output.Add("hpfperf", frame, thread, (hpf * 1050) / cycles); // "page fault and return is about 1050 cycles" - Linus Torvalds } } // Return the results return(output); }