/// <summary> /// Starts recording data for the Profiler /// </summary> /// <param name="historyLength">The amount of ticks to keep in memory</param> public static void Start(int historyLength) { if (IsRunning) { return; } EventIdCounter = 0; Ticks = new FixedQueue <ProfilerTick>(historyLength); tickHistory = historyLength; CurrentTick = null; IsRunning = true; }
internal static void EndTick() { if (!IsRunning) { return; } if (CurrentTick == null) { return; } CurrentTick = null; }
/// <summary> /// Creates a ProfilerTick from data in the provided stream /// </summary> /// <param name="stream">The stream containing the ProfilerTick data</param> /// <returns>The ProfilerTick with data read from the stream</returns> public static ProfilerTick FromStream(Stream stream) { ProfilerTick tick = new ProfilerTick(); using (PooledBitReader reader = PooledBitReader.Get(stream)) { ushort count = reader.ReadUInt16Packed(); for (int i = 0; i < count; i++) { tick.Events.Add(TickEvent.FromStream(stream)); } return(tick); } }
/// <summary> /// Stops recording data and fills the buffer with the recorded ticks and returns the length; /// </summary> /// <param name="tickBuffer">The buffer to fill with the ticks</param> /// <returns>The number of ticks recorded</returns> public static int Stop(ref List <ProfilerTick> tickBuffer) { if (!isRunning) { return(0); } int iteration = Ticks.Count > tickBuffer.Count ? tickBuffer.Count : Ticks.Count; for (int i = 0; i < iteration; i++) { tickBuffer[i] = Ticks[i]; } Ticks = null; //leave to GC CurrentTick = null; //leave to GC isRunning = false; return(iteration); }
/// <summary> /// Stops recording data and fills the buffer with the recorded ticks and returns the length; /// </summary> /// <param name="tickBuffer">The buffer to fill with the ticks</param> /// <returns>The number of ticks recorded</returns> public static int Stop(ref ProfilerTick[] tickBuffer) { if (!IsRunning) { return(0); } int iteration = Ticks.Count > tickBuffer.Length ? tickBuffer.Length : Ticks.Count; for (int i = 0; i < iteration; i++) { tickBuffer[i] = Ticks[i]; } Ticks = null; //leave to GC s_CurrentTick = null; //leave to GC IsRunning = false; return(iteration); }
internal static void StartTick(TickType type) { if (!isRunning) { return; } if (Ticks.Count == tickHistory) { Ticks.Dequeue(); } ProfilerTick tick = new ProfilerTick() { Type = type, Frame = Time.frameCount, EventId = EventIdCounter }; EventIdCounter++; Ticks.Enqueue(tick); CurrentTick = tick; }
/// <summary> /// Stops recording data /// </summary> public static void Stop() { Ticks = null; //leave to GC CurrentTick = null; //leave to GC isRunning = false; }