using System; using System.Collections.Generic; using Logging.Base; using Logging.Data; using UnityEngine; namespace Logging { public enum RouteEvent { None, Left, Right, Straight, Start, Finish } public readonly struct FPSData : ISerializable { private readonly long timestamp; private readonly int fps; public FPSData(long timestamp, int fps) { this.timestamp = timestamp; this.fps = fps; } public KeyValuePair Serialize() => new KeyValuePair(timestamp, new[] { fps.ToString() }); } public class FPSLogger : SensorDataLogger { public override string Key => "route_events"; private float lastTs = 0f; public float checkInterval = 1f; private int currentFps = -1; private int frameCount = 0; public override void Start() { base.Start(); lastTs = Time.time; } private void Update() { var dif = Time.time - lastTs; frameCount++; if (dif >= checkInterval) { currentFps = (int) (frameCount / dif); lastTs = Time.time; frameCount = 0; } Log(new FPSData(Helpers.RoundToLong(Time.time * 1000f), currentFps)); } public override IEnumerable ReadLog(IEnumerable> lines) { throw new NotImplementedException(); } } }