internal static long GetNumberOfFramesInSet(long realSampleLengthNs, FpsConfig fpsConfig) { float realSampleLengthMs = TimeUnit.Milliseconds.Convert(realSampleLengthNs, TimeUnit.Nanoseconds); float size = realSampleLengthMs / fpsConfig.DeviceRefreshRateInMs; return((long)Math.Round(size)); }
/// <summary> /// stops the frame callback and foreground listener /// nulls out static variables /// called from FPSLibrary in a static context /// </summary> /// <param name="context">Context.</param> internal static void Hide(Context context) { // tell callback to stop registering itself fpsFrameCallback.Enabled = false; Foreground.SharedInstance(context).RemoveListener(foregroundListener); // remove the view from the window tinyCoach.Destroy(); // null it all out tinyCoach = null; fpsFrameCallback = null; fpsConfig = null; }
public static KeyValuePair <Metric, long> CalculateMetric(FpsConfig fpsConfig, List <long> dataSet, List <int> droppedSet) { var timeInNS = dataSet.Last() - dataSet.First(); var size = GetNumberOfFramesInSet(timeInNS, fpsConfig); //metric int runningOver = 0; // total dropped int dropped = 0; foreach (var k in droppedSet) { dropped += k; if (k >= 2) { runningOver += k; } } var multiplier = fpsConfig.RefreshRate / size; var answer = multiplier * (size - dropped); var realAnswer = (long)Math.Round(answer); // calculate metric var percentOver = runningOver / (float)size; var metric = Metric.Good; if (percentOver >= fpsConfig.RedFlagPercentage) { metric = Metric.Bad; } else if (percentOver >= fpsConfig.YellowFlagPercentage) { metric = Metric.Medium; } return(new KeyValuePair <Metric, long>(metric, realAnswer)); }
public static List <int> GetDroppedSet(FpsConfig fpsConfig, List <long> dataSet) { var droppedSet = new List <int>(); long start = -1; foreach (var item in dataSet) { if (start == -1) { start = item; continue; } var droppedCount = DroppedCount(start, item, fpsConfig.DeviceRefreshRateInMs); if (droppedCount > 0) { droppedSet.Add(droppedCount); } start = item; } return(droppedSet); }
public FpsFrameCallback(FpsConfig fpsConfig, TinyCoach tinyCoach) { this.fpsConfig = fpsConfig; this.tinyCoach = tinyCoach; dataSet = new List <long>(); }
internal TinyDancerBuilder() { fpsConfig = new FpsConfig(); }