Ejemplo n.º 1
0
        public virtual WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo)
        {
            // if there are no files, presume the full beatmap info has not yet been fetched from the database.
            if (beatmapInfo?.BeatmapSet?.Files.Count == 0)
            {
                int lookupId = beatmapInfo.ID;
                beatmapInfo = BeatmapManager.QueryBeatmap(b => b.ID == lookupId);
            }

            if (beatmapInfo?.BeatmapSet == null)
            {
                return(DefaultBeatmap);
            }

            lock (workingCache)
            {
                var working = workingCache.FirstOrDefault(w => beatmapInfo.Equals(w.BeatmapInfo));

                if (working != null)
                {
                    return(working);
                }

                beatmapInfo.Metadata ??= beatmapInfo.BeatmapSet.Metadata;

                workingCache.Add(working = new BeatmapManagerWorkingBeatmap(beatmapInfo, this));

                // best effort; may be higher than expected.
                GlobalStatistics.Get <int>(nameof(Beatmaps), $"Cached {nameof(WorkingBeatmap)}s").Value = workingCache.Count();

                return(working);
            }
        }
        private void load()
        {
            Children = new[]
            {
                display = new GlobalStatisticsDisplay(),
            };

            display.ToggleVisibility();

            GlobalStatistic <double> stat = null;

            AddStep("Register test statistic", () => stat = GlobalStatistics.Get <double>("TestCase", "Test Statistic"));

            AddStep("Change value once", () => stat.Value  = 10);
            AddStep("Change value again", () => stat.Value = 20);

            AddStep("Register statistics non-alphabetically", () =>
            {
                GlobalStatistics.Get <int>("ZZZZZ", "BBBBB");
                GlobalStatistics.Get <int>("ZZZZZ", "AAAAA");
            });

            AddStep("Register groups non-alphabetically", () =>
            {
                GlobalStatistics.Get <int>("XXXXX", "BBBBB");
                GlobalStatistics.Get <int>("TTTTT", "AAAAA");
            });
        }
Ejemplo n.º 3
0
        public virtual WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo)
        {
            if (beatmapInfo?.BeatmapSet == null)
            {
                return(DefaultBeatmap);
            }

            lock (workingCache)
            {
                var working = workingCache.FirstOrDefault(w => beatmapInfo.Equals(w.BeatmapInfo));

                if (working != null)
                {
                    return(working);
                }

                beatmapInfo = beatmapInfo.Detach();

                workingCache.Add(working = new BeatmapManagerWorkingBeatmap(beatmapInfo, this));

                // best effort; may be higher than expected.
                GlobalStatistics.Get <int>("Beatmaps", $"Cached {nameof(WorkingBeatmap)}s").Value = workingCache.Count();

                return(working);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a new pool instance.
        /// </summary>
        /// <param name="initialSize">The number of drawables to be prepared for initial consumption.</param>
        /// <param name="maximumSize">An optional maximum size after which the pool will no longer be expanded.</param>
        public DrawablePool(int initialSize, int?maximumSize = null)
        {
            this.maximumSize = maximumSize;
            this.initialSize = initialSize;

            int id = Interlocked.Increment(ref poolInstanceID);

            statistic       = GlobalStatistics.Get <DrawablePoolUsageStatistic>(nameof(DrawablePool <T>), typeof(T).ReadableName() + $"`{id}");
            statistic.Value = new DrawablePoolUsageStatistic();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Retrieve a <see cref="WorkingBeatmap"/> instance for the provided <see cref="BeatmapInfo"/>
        /// </summary>
        /// <param name="beatmapInfo">The beatmap to lookup.</param>
        /// <param name="previous">The currently loaded <see cref="WorkingBeatmap"/>. Allows for optimisation where elements are shared with the new beatmap. May be returned if beatmapInfo requested matches</param>
        /// <returns>A <see cref="WorkingBeatmap"/> instance correlating to the provided <see cref="BeatmapInfo"/>.</returns>
        public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null)
        {
            if (beatmapInfo?.ID > 0 && previous != null && previous.BeatmapInfo?.ID == beatmapInfo.ID)
            {
                return(previous);
            }

            if (beatmapInfo?.BeatmapSet == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo)
            {
                return(DefaultBeatmap);
            }

            if (beatmapInfo.BeatmapSet.Files == null)
            {
                var info = beatmapInfo;
                beatmapInfo = QueryBeatmap(b => b.ID == info.ID);
            }

            if (beatmapInfo == null)
            {
                return(DefaultBeatmap);
            }

            lock (workingCache)
            {
                var working = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == beatmapInfo.ID);
                if (working != null)
                {
                    return(working);
                }

                beatmapInfo.Metadata ??= beatmapInfo.BeatmapSet.Metadata;

                workingCache.Add(working = new BeatmapManagerWorkingBeatmap(beatmapInfo, this));

                // best effort; may be higher than expected.
                GlobalStatistics.Get <int>(nameof(Beatmaps), $"Cached {nameof(WorkingBeatmap)}s").Value = workingCache.Count();

                return(working);
            }
        }
        public void TestUpdateStats()
        {
            GlobalStatistic <double> stat = null;

            AddStep("Register test statistic", () => stat = GlobalStatistics.Get <double>("TestCase", "Test Statistic"));

            AddStep("Change value once", () => stat.Value  = 10);
            AddStep("Change value again", () => stat.Value = 20);

            AddStep("Register statistics non-alphabetically", () =>
            {
                GlobalStatistics.Get <int>("ZZZZZ", "BBBBB");
                GlobalStatistics.Get <int>("ZZZZZ", "AAAAA");
            });

            AddStep("Register groups non-alphabetically", () =>
            {
                GlobalStatistics.Get <int>("XXXXX", "BBBBB");
                GlobalStatistics.Get <int>("TTTTT", "AAAAA");
            });
        }
Ejemplo n.º 7
0
 private static GlobalStatistic <long> getStatistic(object source) => GlobalStatistics.Get <long>("Native", source.GetType().Name);