// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections.Generic; namespace osu.Framework.Statistics { internal class FrameStatistics { internal readonly Dictionary CollectedTimes = new Dictionary(NUM_STATISTICS_COUNTER_TYPES); internal readonly Dictionary Counts = new Dictionary(NUM_STATISTICS_COUNTER_TYPES); internal readonly List GarbageCollections = new List(); public double FramesPerSecond { get; set; } internal static readonly int NUM_STATISTICS_COUNTER_TYPES = Enum.GetValues(typeof(StatisticsCounterType)).Length; internal static readonly int NUM_PERFORMANCE_COLLECTION_TYPES = Enum.GetValues(typeof(PerformanceCollectionType)).Length; internal static readonly long[] COUNTERS = new long[NUM_STATISTICS_COUNTER_TYPES]; internal void Clear() { CollectedTimes.Clear(); GarbageCollections.Clear(); Counts.Clear(); FramesPerSecond = 0; } internal static void Increment(StatisticsCounterType type) => ++COUNTERS[(int)type]; internal static void Add(StatisticsCounterType type, long amount) => COUNTERS[(int)type] += amount; } internal enum PerformanceCollectionType { Work = 0, SwapBuffer, WndProc, Debug, Sleep, Scheduler, IPC, GLReset, } internal enum StatisticsCounterType { Invalidations = 0, Refreshes, DrawNodeCtor, DrawNodeAppl, ScheduleInvk, InputQueue, PositionalIQ, /// /// See . /// CCL, VBufBinds, VBufOverflow, TextureBinds, FBORedraw, DrawCalls, ShaderBinds, VerticesDraw, VerticesUpl, Pixels, TasksRun, Tracks, Samples, SChannels, Components, MixChannels, MouseEvents, KeyEvents, JoystickEvents, MidiEvents, TabletEvents, } }