예제 #1
0
        internal static void FinalizerReport(bool criticalFinalizers, string logFileName, string startMarker, string endMarker)
        {
            // first read the entire file
            ReadNewLog log = new ReadNewLog(logFileName, false);
            ReadLogResult entireLogResult = GetLogResult(log);
            log.ReadFile(0, long.MaxValue, entireLogResult);

            // if we were given a start or an end marker, we need to re-read a portion of the file.
            ReadLogResult logResult = entireLogResult;
            if (startMarker != null || endMarker != null)
            {
                int startTickIndex = 0;
                int endTickIndex = entireLogResult.sampleObjectTable.lastTickIndex;

                if (startMarker != null)
                    startTickIndex = FindMarkerTickIndex(startMarker, log);

                if (endMarker != null)
                    endTickIndex = FindMarkerTickIndex(endMarker, log);

                long startPos = log.TickIndexToPos(startTickIndex);
                long endPos = log.TickIndexToPos(endTickIndex);

                // Read the selected portion of the log again
                logResult = new ReadLogResult();
                logResult.liveObjectTable = new LiveObjectTable(log);
                logResult.finalizerHistogram = new Histogram(log);
                logResult.criticalFinalizerHistogram = new Histogram(log);

                log.ReadFile(startPos, endPos, logResult);

                if (startMarker == null)
                    startMarker = CommentRangeForm.startCommentString;
                if (endMarker == null)
                    endMarker = CommentRangeForm.shutdownCommentString;
                Console.WriteLine("{0} summary for {1} Objects between {2} ({3} secs) and {4} ({5} secs)",
                                    criticalFinalizers ? "Critical Finalized" : "Finalized",
                                                    logFileName, 
                                                                startMarker, 
                                                                     log.TickIndexToTime(startTickIndex),
                                                                                   endMarker,
                                                                                        log.TickIndexToTime(endTickIndex));
            }
            else
                Console.WriteLine("{0} summary for {1}",
                                    criticalFinalizers ? "Critical Finalized" : "Finalized",
                                                    logFileName);

            // now we are ready to produce the allocation report from the allocation histogram
            WriteReport(criticalFinalizers ? logResult.criticalFinalizerHistogram : logResult.finalizerHistogram, "");
        }
예제 #2
0
        internal static Histogram GetSurvivorHistogram(ReadNewLog log, ReadLogResult entireLogResult, int startTickIndex, int endTickIndex, string timeMarker)
        {
            ReadLogResult logResult = entireLogResult;
            int timeTickIndex = entireLogResult.sampleObjectTable.lastTickIndex;
            if (timeMarker != null)
            {
                timeTickIndex = FindMarkerTickIndex(timeMarker, log);

                long endPos = log.TickIndexToPos(timeTickIndex);

                // Read the selected portion of the log again
                logResult = new ReadLogResult();
                logResult.liveObjectTable = new LiveObjectTable(log);
                log.ReadFile(0, endPos, logResult);
            }

            Histogram histogram = new Histogram(log);
            LiveObjectTable.LiveObject o;
            for (logResult.liveObjectTable.GetNextObject(0, ulong.MaxValue, out o);
                o.id < ulong.MaxValue;
                logResult.liveObjectTable.GetNextObject(o.id + o.size, ulong.MaxValue, out o))
            {
                if (startTickIndex <= o.allocTickIndex && o.allocTickIndex < endTickIndex)
                    histogram.AddObject(o.typeSizeStacktraceIndex, 1);
            }

            return histogram;
        }