Esempio n. 1
0
        private void Summarize(FileAccessMarker thisFileAccessMarker)
        {
            if (m_CaptureData.m_FileSummaryData.ContainsKey(thisFileAccessMarker.filename))
            {
                m_TempFileSummary = m_CaptureData.m_FileSummaryData[thisFileAccessMarker.filename];
            }
            else
            {
                m_TempFileSummary                  = new FileSummary();
                m_TempFileSummary.filename         = thisFileAccessMarker.filename;
                m_TempFileSummary.readableFileName = thisFileAccessMarker.readableFileName;
                m_TempFileSummary.readablePath     = thisFileAccessMarker.readablePath;
                m_TempFileSummary.firstFrame       = thisFileAccessMarker.firstFrameIndex;

                m_CaptureData.m_FileSummaryData.Add(thisFileAccessMarker.filename, m_TempFileSummary);
            }

            switch (thisFileAccessMarker.type)
            {
            case FileAccessType.Open:
                m_TempFileSummary.opened++;
                m_TempFileSummary.openAccessMs += thisFileAccessMarker.ms;
                break;

            case FileAccessType.Close:
                m_TempFileSummary.closed++;
                m_TempFileSummary.closeAccessMs += thisFileAccessMarker.ms;
                break;

            case FileAccessType.Read:
                m_TempFileSummary.reads++;
                m_TempFileSummary.bytesRead    += thisFileAccessMarker.sizeBytes;
                m_TempFileSummary.readAccessMs += thisFileAccessMarker.ms;
                break;

            case FileAccessType.Write:
                m_TempFileSummary.writes++;
                m_TempFileSummary.bytesWritten  += thisFileAccessMarker.sizeBytes;
                m_TempFileSummary.writeAccessMs += thisFileAccessMarker.ms;
                break;

            case FileAccessType.Seek:
                m_TempFileSummary.seeks++;
                m_TempFileSummary.seekAccessMs += thisFileAccessMarker.ms;
                break;

            default:
                break;
            }

            m_TempFileSummary.accesses++;
            m_TempFileSummary.totalAccessMs += thisFileAccessMarker.ms;

            if (thisFileAccessMarker.firstFrameIndex < m_TempFileSummary.firstFrame)
            {
                m_TempFileSummary.firstFrame = thisFileAccessMarker.firstFrameIndex;
            }

            for (int frameIndex = thisFileAccessMarker.firstFrameIndex; frameIndex <= thisFileAccessMarker.lastFrameIndex; frameIndex++)
            {
                if (!m_TempFileSummary.frameIndices.Contains(frameIndex))
                {
                    m_TempFileSummary.frameIndices.Add(frameIndex);
                }
            }
        }
Esempio n. 2
0
 internal static void FileCloseMetadataFiller(ref FileAccessMarker marker, RawFrameDataView frameData, int sampleIndex)
 {
     // Filename
     marker.filename = frameData.GetSampleMetadataAsString(sampleIndex, 0);
 }
Esempio n. 3
0
        public static void PullDataStatic(ref FileAccessCaptureData captureData, Dictionary <string, FileAccessMarkerInfo> markers, ref Dictionary <string, int> markerToIDMap, int firstFrameIndex, int lastFrameIndex)
        {
            string error = null;

            captureData.m_FileAccessData.Clear();
            captureData.m_StartTimeNs = ulong.MaxValue;
            captureData.m_EndTimeNs   = ulong.MinValue;

            ProfilerFrameDataIterator frameIter = new ProfilerFrameDataIterator();
            double nsFrameStart;

            for (int frameIndex = firstFrameIndex; frameIndex <= lastFrameIndex; ++frameIndex)
            {
                frameIter.SetRoot(frameIndex, 0);

                int threadCount = frameIter.GetThreadCount(frameIndex);
                // iterate over the threads
                for (int threadIndex = 0; threadIndex < threadCount; ++threadIndex)
                {
                    using (RawFrameDataView frameData = ProfilerDriver.GetRawFrameDataView(frameIndex, threadIndex))
                    {
                        if (!frameData.valid)
                        {
                            break;
                        }

                        nsFrameStart = frameData.frameStartTimeNs;
                        if (frameIndex == firstFrameIndex)
                        {
                            if (captureData.m_StartTimeNs > nsFrameStart)
                            {
                                captureData.m_StartTimeNs = nsFrameStart;
                            }
                        }

                        GetMarkerIDs(frameData, markers, ref markerToIDMap);

                        string fullThreadName = GetFullThreadName(frameData.threadGroupName, frameData.threadName);

                        // iterate over the samples to collect up any markers
                        int sampleCount = frameData.sampleCount;
                        for (int i = 0; i < sampleCount; ++i)
                        {
                            s_CheckSamples.Begin();
                            int markerId = frameData.GetSampleMarkerId(i);
                            if (markerId == FrameDataView.invalidMarkerId || !markerToIDMap.ContainsValue(markerId))
                            {
                                s_CheckSamples.End();
                                continue;
                            }

                            string markerName = frameData.GetMarkerName(markerId);
                            Assert.IsTrue(markers.ContainsKey(markerName), string.Format("Marker {0} is not present in requested markers.", markerName));

                            s_CheckSamples.End();

                            s_AddNewMarker.Begin();

                            ulong markerStartTimeNs = Math.Max(frameData.GetSampleStartTimeNs(i) - (ulong)captureData.m_StartTimeNs, 0);
                            ulong sampleLengthNs    = frameData.GetSampleTimeNs(i);

                            // if the marker isn't a continuation of a previous marker, add a new access
                            if (!CheckForContinuationMarker(frameData, ref captureData, threadIndex, markerId, frameIndex, i, markerStartTimeNs, sampleLengthNs))
                            {
                                FileAccessMarker fileAccessMarker = new FileAccessMarker(frameIndex, threadIndex, i);

                                // fill in contexts from Metadata
                                FileAccessMarkerInfo markerInfo = markers[markerName];
                                if (markerInfo.metadataCount == frameData.GetSampleMetadataCount(i))
                                {
                                    markerInfo.metaDataFiller(ref fileAccessMarker, frameData, i);
                                }
                                else if (error == null) // Check the error is only shown once
                                {
                                    error = $"Some markers, such as '{markerName}', have unexpected metadata. This may be because of opening a profile captured with an older version of Unity. Certain values may be missing.";
                                    Debug.LogWarning(error);
                                }

                                if (string.IsNullOrEmpty(fileAccessMarker.filename))
                                {
                                    fileAccessMarker.readablePath     = "Unknown path";
                                    fileAccessMarker.readableFileName = "?";
                                }
                                else
                                {
                                    fileAccessMarker.readablePath     = fileAccessMarker.filename;
                                    fileAccessMarker.readableFileName = Path.GetFileName(fileAccessMarker.readablePath);
                                    if (fileAccessMarker.readablePath.Contains("/Analytics/"))
                                    {
                                        fileAccessMarker.readableFileName += " (Analytics)";
                                    }
                                }

                                fileAccessMarker.startNs  = markerStartTimeNs;
                                fileAccessMarker.lengthNs = sampleLengthNs;
                                fileAccessMarker.endNs    = markerStartTimeNs + sampleLengthNs;

                                fileAccessMarker.startTimeMs = markerStartTimeNs * 0.000001;
                                fileAccessMarker.ms          = fileAccessMarker.lengthNs * 0.000001;

                                fileAccessMarker.markerId   = markerId;
                                fileAccessMarker.type       = markerInfo.fileAccessType;
                                fileAccessMarker.markerName = markerName;
                                fileAccessMarker.threadName = fullThreadName;
                                fileAccessMarker.threadId   = frameData.threadId;

                                captureData.m_FileAccessData.Add(fileAccessMarker);
                            }
                            s_AddNewMarker.End();
                        }
                    }
                }
            }

            foreach (var fileAccessMarker in captureData.m_FileAccessData)
            {
                fileAccessMarker.averageBandwidthMBps = (fileAccessMarker.ms > 0) ? ((float)fileAccessMarker.sizeBytes / (float)fileAccessMarker.ms) * 0.001f : 0.0f;
            }

            frameIter.Dispose();
        }
Esempio n. 4
0
 public FileAccessTreeViewItem(int id, int depth, string displayName, FileAccessMarker data) : base(id, depth, displayName)
 {
     fileAccessMarker = data;
 }