Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        /// <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;
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 public FpsFrameCallback(FpsConfig fpsConfig, TinyCoach tinyCoach)
 {
     this.fpsConfig = fpsConfig;
     this.tinyCoach = tinyCoach;
     dataSet        = new List <long>();
 }
Esempio n. 6
0
 internal TinyDancerBuilder()
 {
     fpsConfig = new FpsConfig();
 }