コード例 #1
0
ファイル: Memory.cs プロジェクト: lelonek1/perfview-1
            public string DumpRanges()
            {
                StringWriter sw = new StringWriter();

                foreach (int ipi in sortedMemInfos)
                {
                    MemInfo p = memInfos[ipi];

                    if (p.cCommitted == 0 && p.cDecommitted == 0 && p.cReleased == 0 && p.cReserved == 0)
                    {
                        continue;
                    }

                    sw.WriteLine("Live ranges for {0}", ByteWindow.MakeString(p.processPid));
                    sw.WriteLine();
                    sw.WriteLine("RESERVED  ({0} ranges)", p.rsReserved.RangeCount);
                    sw.WriteLine();
                    sw.WriteLine(p.rsReserved.Dump());
                    sw.WriteLine();
                    sw.WriteLine("COMMITTED ({0} ranges)", p.rsCommitted.RangeCount);
                    sw.WriteLine();
                    sw.WriteLine(p.rsCommitted.Dump());
                    sw.WriteLine();
                }

                return(sw.ToString());
            }
コード例 #2
0
        public ETLTrace(ITraceParameters itparms, ITraceUINotify itnotify, string filename)
        {
            this.filename      = filename;
            this.initial_parms = itparms; // the original parameters
            this.itparms       = itparms;
            this.itnotify      = itnotify;

            stm = new BigStream(filename);

            if (!TryLoadState())
            {
                InitializeFromPrimary();
            }
            else
            {
                itnotify.ClearEventFields();

                foreach (TimeMark t in listInitialTime)
                {
                    itnotify.AddTimeToTimeList(t.desc);
                }
            }

            for (int i = 0; i < atomsRecords.Count; i++)
            {
                if (recordInfo[i].count > 0)
                {
                    itnotify.AddEventToEventList(atomsRecords.MakeString(i));
                }
            }

            for (int i = 0; i < sortedThreads.Length; i++)
            {
                ThreadInfo ti = threads[sortedThreads[i]];
                itnotify.AddThreadToThreadList(String.Format("{0,20} {1,5} {2}", ByteWindow.MakeString(ti.processPid), ti.threadid, ByteWindow.MakeString(ti.threadproc)));
            }

            for (int i = 0; i < processes.Count; i++)
            {
                ProcessInfo pi = processes[sortedProcesses[i]];
                itnotify.AddProcessToProcessList(ByteWindow.MakeString(pi.processPid));
            }

            for (int i = 0; i < stackTypes.Length; i++)
            {
                if (stackTypes[i])
                {
                    itnotify.AddEventToStackEventList(atomsRecords.MakeString(i));
                }
            }
        }
コード例 #3
0
ファイル: Memory.cs プロジェクト: lelonek1/perfview-1
            public string DumpMemoryPlots()
            {
                if (sortedMemInfos == null || sortedMemInfos.Length < 1)
                {
                    return("");
                }

                StringWriter sw = new StringWriter();

                sw.WriteLine();
                sw.WriteLine("VM PLOTS FOR SELECTED PROCESSES");
                sw.WriteLine();

                int count = 0;

                foreach (int ipi in sortedMemInfos)
                {
                    MemInfo p = memInfos[ipi];

                    if (p.cCommitted == 0 && p.cDecommitted == 0 && p.cReleased == 0 && p.cReserved == 0)
                    {
                        continue;
                    }

                    sw.WriteLine();
                    sw.WriteLine();

                    string xLabel = String.Format("Usage from {0}", ByteWindow.MakeString(p.processPid));
                    string yLabel = "Reserved Bytes";

                    sw.WriteLine(FormatOnePlot(memoryPlotRows, memoryPlotColumns, xLabel, yLabel, p.reservedDistribution));

                    sw.WriteLine();
                    sw.WriteLine();

                    xLabel = String.Format("Usage from {0}", ByteWindow.MakeString(p.processPid));
                    yLabel = "Committed Bytes";

                    sw.WriteLine(FormatOnePlot(memoryPlotRows, memoryPlotColumns, xLabel, yLabel, p.committedDistribution));

                    count++;

                    if (count >= 3)
                    {
                        break;
                    }
                }

                return(sw.ToString());
            }
コード例 #4
0
ファイル: CSwitch.cs プロジェクト: ScriptBox21/MS-perfview
        public string ComputeDelays(int delaySize)
        {
            ThreadStat[] stats = NewThreadStats();

            bool[] threadFilters = itparms.GetThreadFilters();
            int    idCSwitch     = atomsRecords.Lookup("CSwitch");

            StringWriter sw = new StringWriter();

            sw.WriteLine("{0,15} {1,15} {2,15} {3,30} {4,5} {5,-60}", "Delay Start", "Delay End", "Delay Duration", "Process Name ( ID )", "TID", "Threadproc");
            sw.WriteLine("{0,15} {1,15} {2,15} {3,30} {4,5} {5,-60}", "-----------", "---------", "--------------", "-------------------", "---", "----------");

            listDelays = new List <TimeMark>();

            int  totalDelays = 0;
            long totalDelay  = 0;

            long T0 = itparms.T0;

            for (int i = 0; i < stats.Length; i++)
            {
                stats[i].time = Math.Max(T0, threads[i].timestamp);
            }

            ETWLineReader l = StandardLineReader();

            foreach (ByteWindow b in l.Lines())
            {
                if (l.idType != idCSwitch)
                {
                    continue;
                }

                int oldTid = b.GetInt(fldCSwitchOldTID);
                int idxOld = FindThreadInfoIndex(l.t, oldTid);
                stats[idxOld].time = l.t;

                int newTid = b.GetInt(fldCSwitchNewTID);
                int idxNew = FindThreadInfoIndex(l.t, newTid);

                int waitTime = (int)(l.t - stats[idxNew].time);

                if (waitTime <= 0)
                {
                    continue;
                }

                if (!threadFilters[idxNew])
                {
                    continue;
                }

                totalDelays++;
                totalDelay += waitTime;

                if (waitTime > delaySize)
                {
                    TimeMark tm = new TimeMark();
                    tm.t0 = l.t - waitTime;
                    tm.t1 = l.t;

                    string process    = ByteWindow.MakeString(threads[idxNew].processPid);
                    string threadproc = ByteWindow.MakeString(threads[idxNew].threadproc);

                    tm.desc = String.Format("{0,15:n0} {1,15:n0} {2,15:n0} {3,30} {4,5} {5,-60}", tm.t0, tm.t1, waitTime, process, newTid, threadproc);
                    sw.WriteLine(tm.desc);

                    listDelays.Add(tm);
                }
            }

            sw.WriteLine();
            sw.WriteLine("Total Delays: {0:n0}  Total Delay Time {1:n0}", totalDelays, totalDelay);

            return(sw.ToString());
        }
コード例 #5
0
ファイル: CSwitch.cs プロジェクト: ScriptBox21/MS-perfview
        public string FormatContextSwitchResult(ContextSwitchResult results)
        {
            int nTop = results.nTop;

            string[] reasonNames = new string[atomsReasons.Count];
            for (int i = 0; i < reasonNames.Length; i++)
            {
                reasonNames[i] = atomsReasons.MakeString(i);
            }

            ThreadStat[] stats = results.stats;

            int ithreadIdle = IdleThreadIndex;
            int iStatsIdle  = 0;

            // find where the idle thread landed after sorting
            for (int i = 0; i < stats.Length; i++)
            {
                if (stats[i].ithread == ithreadIdle)
                {
                    iStatsIdle = i;
                    break;
                }
            }

            StringWriter sw = new StringWriter();

            sw.WriteLine("Start time: {0:n0}   End time: {1:n0}  Interval Length: {2:n0}", tStart, tEnd, tEnd - tStart);
            sw.WriteLine();

            sw.WriteLine("CPUs: {0:n0}, Total CPU Time: {1:n0} usec. Total Switches: {2:n0} Idle: {3,5:f1}%  Busy: {4,5:f1}%",
                         results.countCPU,
                         results.timeTotal,
                         results.switchesTotal,
                         stats[iStatsIdle].time * 100.0 / results.timeTotal,
                         (results.timeTotal - stats[iStatsIdle].time) * 100.0 / results.timeTotal);
            sw.WriteLine();

            sw.WriteLine("{0,20} {1,17} {2,35} {3,5} {4,32} {5}", "        Time (usec)", "       Switches", "Process ( PID)", " TID", "Run Mask", "ThreadProc");
            sw.WriteLine("{0,20} {1,17} {2,35} {3,5} {4,32} {5}", "-------------------", "---------------", "--------------", "----", "--------", "----------");

            char[] maskChars = new char[32];

            for (int i = 0; i < Math.Min(threads.Count, nTop); i++)
            {
                int ithread = stats[i].ithread;

                if (stats[i].time == 0)
                {
                    continue;
                }

                if (!results.threadFilters[ithread])
                {
                    continue;
                }

                for (int bit = 0; bit < 32; bit++)
                {
                    maskChars[bit] = ((stats[i].runmask & (1 << bit)) != 0 ? 'X' : '_');
                }

                sw.WriteLine("{0,11:n0} ({1,5:f1}%) {2,8:n0} ({3,5:f1}%) {4,35} {5,5} {6} {7}",
                             stats[i].time,
                             stats[i].time * 100.0 / results.timeTotal,
                             stats[i].switches,
                             stats[i].switches * 100.0 / results.switchesTotal,
                             ByteWindow.MakeString(threads[ithread].processPid),
                             threads[ithread].threadid,
                             new String(maskChars),
                             ByteWindow.MakeString(threads[ithread].threadproc)
                             );

                if (results.reasonsComputed)
                {
                    int[] swapReasons = stats[i].swapReasons;

                    if (swapReasons != null)
                    {
                        for (int k = 0; k < swapReasons.Length; k++)
                        {
                            if (swapReasons[k] > 0)
                            {
                                sw.WriteLine("          {0,17} {1}", reasonNames[k], swapReasons[k]);
                            }
                        }
                    }

                    sw.WriteLine();
                }
            }

            if (results.fSimulateHyperthreading)
            {
                sw.WriteLine();
                sw.WriteLine("Hyperthreading Simulation was used to attribute idle cost more accurately");
            }

            return(sw.ToString());
        }
コード例 #6
0
ファイル: Memory.cs プロジェクト: lelonek1/perfview-1
            public string Dump()
            {
                StringWriter sw = new StringWriter();

                SortMemInfos();

                sw.WriteLine("VM CHANGES IN THIS INTERVAL");
                sw.WriteLine();

                sw.WriteLine("{8,-35} {0,14} {1,14} {2,14} {3,14} {4,14} {5,14} {6,14} {7,14}",
                             "Reserved", "Count",
                             "Committed", "Count",
                             "Decomitt", "Count",
                             "Released", "Count",
                             "Process");

                sw.WriteLine("{8,-35} {0,14} {1,14} {2,14} {3,14} {4,14} {5,14} {6,14} {7,14}",
                             "---------", "-----",
                             "---------", "-----",
                             "--------", "-----",
                             "--------", "-----",
                             "-------");

                foreach (int ipi in sortedMemInfos)
                {
                    MemInfo p = memInfos[ipi];

                    if (p.cCommitted == 0 && p.cDecommitted == 0 && p.cReleased == 0 && p.cReserved == 0)
                    {
                        continue;
                    }

                    sw.WriteLine("{8,-35} {0,14:n0} {1,14:n0} {2,14:n0} {3,14:n0} {4,14:n0} {5,14:n0} {6,14:n0} {7,14:n0}"
                                 , p.cbReserved
                                 , p.cReserved
                                 , p.cbCommitted
                                 , p.cCommitted
                                 , p.cbDecommitted
                                 , p.cDecommitted
                                 , p.cbReleased
                                 , p.cReleased
                                 , ByteWindow.MakeString(p.processPid)
                                 );
                }

                sw.WriteLine();
                sw.WriteLine("VM ALLOCATED AT END OF THIS INTERVAL");
                sw.WriteLine();


                sw.WriteLine("{4,-35} {0,14} {1,14} {2,14} {3,14}",
                             "Reserved", "Ranges",
                             "Committed", "Ranges",
                             "Process");

                sw.WriteLine("{4,-35} {0,14} {1,14} {2,14} {3,14}",
                             "--------", "------",
                             "---------", "------",
                             "-------");

                foreach (int ipi in sortedMemInfos)
                {
                    MemInfo p = memInfos[ipi];

                    if (p.cCommitted == 0 && p.cDecommitted == 0 && p.cReleased == 0 && p.cReserved == 0)
                    {
                        continue;
                    }

                    sw.WriteLine("{4,-35} {0,14:n0} {1,14:n0} {2,14:n0} {3,14:n0}"
                                 , p.rsReserved.Count
                                 , p.rsReserved.RangeCount
                                 , p.rsCommitted.Count
                                 , p.rsCommitted.RangeCount
                                 , ByteWindow.MakeString(p.processPid)
                                 );
                }

                return(sw.ToString());
            }
コード例 #7
0
 public string MakeString(int id)
 {
     return(ByteWindow.MakeString(GetBytes(id)));
 }