示例#1
0
        public static int GetNames(List <string> names)
        {
            var availableMarkers = new List <ProfilerRecorderHandle>();

            ProfilerRecorderHandle.GetAvailable(availableMarkers);

            if (names != null)
            {
                if (names.Count < availableMarkers.Count)
                {
                    names.Capacity = availableMarkers.Count;
                    for (int i = names.Count; i < availableMarkers.Count; i++)
                    {
                        names.Add(null);
                    }
                }

                int index = 0;
                foreach (var h in availableMarkers)
                {
                    var statDesc = ProfilerRecorderHandle.GetDescription(h);
                    names[index] = statDesc.Name;
                    index++;
                }
            }

            return(availableMarkers.Count);
        }
        public void LoadEditorCounters(out SortedDictionary <string, List <string> > systemCounters, out SortedDictionary <string, List <string> > userCounters)
        {
            userCounters   = new SortedDictionary <string, List <string> >();
            systemCounters = new SortedDictionary <string, List <string> >();

            var availableCounterHandles = new List <ProfilerRecorderHandle>();

            ProfilerRecorderHandle.GetAvailable(availableCounterHandles);
            foreach (var availableCounterHandle in availableCounterHandles)
            {
                var markerInfo = ProfilerRecorderHandle.GetDescription(availableCounterHandle);
                if ((markerInfo.Flags & MarkerFlags.Counter) == 0)
                {
                    continue;
                }

                var counterName  = markerInfo.Name;
                var categoryName = markerInfo.Category.Name;
                if ((markerInfo.Flags & MarkerFlags.Script) != 0)
                {
                    AddToCountersCollection(categoryName, counterName, userCounters);
                }
                else
                {
                    AddToCountersCollection(categoryName, counterName, systemCounters);
                }
            }
        }
示例#3
0
        private static ProfilerRecorder Create(ProfilerRecorderHandle statHandle, int maxSampleCount, ProfilerRecorderOptions options)
        {
            ProfilerRecorder result;

            ProfilerRecorder.Create_Injected(ref statHandle, maxSampleCount, options, out result);
            return(result);
        }
        public static Recorder Get(string samplerName)
        {
            var handler = ProfilerRecorderHandle.Get(ProfilerCategory.Any, samplerName);

            if (!handler.Valid)
            {
                return(s_InvalidRecorder);
            }
            return(new Recorder(handler));
        }
        internal Recorder(ProfilerRecorderHandle handle)
        {
            if (!handle.Valid)
            {
                return;
            }

            m_RecorderCPU = new ProfilerRecorder(handle, 1, s_RecorderDefaultOptions);

            var description = ProfilerRecorderHandle.GetDescription(handle);

            if ((description.Flags & MarkerFlags.SampleGPU) != 0)
            {
                m_RecorderGPU = new ProfilerRecorder(handle, 1, s_RecorderDefaultOptions | ProfilerRecorderOptions.GpuRecorder);
            }
        }
示例#6
0
    static unsafe void EnumerateProfilerStats()
    {
        var availableStatHandles = new List <ProfilerRecorderHandle>();

        ProfilerRecorderHandle.GetAvailable(availableStatHandles);

        var availableStats = new List <StatInfo>(availableStatHandles.Count);

        foreach (var h in availableStatHandles)
        {
            var statDesc = ProfilerRecorderHandle.GetDescription(h);
            var statInfo = new StatInfo()
            {
                Cat  = statDesc.Category,
                Name = statDesc.Name,
                Unit = statDesc.UnitType
            };
            availableStats.Add(statInfo);
        }
        availableStats.Sort((a, b) =>
        {
            var result = string.Compare(a.Cat.ToString(), b.Cat.ToString());
            if (result != 0)
            {
                return(result);
            }

            return(string.Compare(a.Name, b.Name));
        });

        var sb = new StringBuilder("Available stats:\n");

        foreach (var s in availableStats)
        {
            sb.AppendLine($"{(int)s.Cat}\t\t - {s.Name}\t\t - {s.Unit}");
        }

        Debug.Log(sb.ToString());
    }
示例#7
0
        public Recorder GetRecorder()
        {
            var handle = new ProfilerRecorderHandle((ulong)m_Ptr.ToInt64());

            return(new Recorder(handle));
        }
示例#8
0
 private static extern void Create_Injected(ref ProfilerRecorderHandle statHandle, int maxSampleCount, ProfilerRecorderOptions options, out ProfilerRecorder ret);
示例#9
0
 public ProfilerRecorder(ProfilerRecorderHandle statHandle, int capacity = 1, ProfilerRecorderOptions options = ProfilerRecorderOptions.Default)
 {
     this = ProfilerRecorder.Create(statHandle, capacity, options);
 }
示例#10
0
 public ProfilerRecorder(ProfilerMarker marker, int capacity = 1, ProfilerRecorderOptions options = ProfilerRecorderOptions.Default)
 {
     this = ProfilerRecorder.Create(ProfilerRecorderHandle.Get(marker), capacity, options);
 }
示例#11
0
        public unsafe ProfilerRecorder(ProfilerCategory category, char *statName, int statNameLen, int capacity = 1, ProfilerRecorderOptions options = ProfilerRecorderOptions.Default)
        {
            ProfilerRecorderHandle byName = ProfilerRecorderHandle.GetByName(category, statName, statNameLen);

            this = ProfilerRecorder.Create(byName, capacity, options);
        }
示例#12
0
        public ProfilerRecorder(ProfilerCategory category, string statName, int capacity = 1, ProfilerRecorderOptions options = ProfilerRecorderOptions.Default)
        {
            ProfilerRecorderHandle byName = ProfilerRecorderHandle.GetByName(category, statName);

            this = ProfilerRecorder.Create(byName, capacity, options);
        }