/// <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; statistic = usage_statistic; }
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"); }); }
private void ReadAllGlobalStatsSuccess(string json, object cb) { m_mainScene.AddLog("SUCCESS"); m_mainScene.AddLogJson(json); m_mainScene.AddLog(""); JsonData jObj = JsonMapper.ToObject(json); JsonData jStats = jObj["data"]["statistics"]; IDictionary dStats = jStats as IDictionary; if (dStats != null) { foreach (string key in dStats.Keys) { GlobalStatistic stat = new GlobalStatistic(); stat.name = (string)key; JsonData value = (JsonData)dStats[key]; // silly that LitJson can't upcast an int to a long... stat.value = value.IsInt ? (int)value : (long)value; m_stats[stat.name] = stat; } } }
/// <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(); }
protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); CountInUse = 0; CountConstructed = 0; CountAvailable = 0; // Disallow any further Gets/Returns to adjust the statistics. statistic = null; }
void ReadGlobalStatsSuccess(string json, object cb) { Dictionary <string, object> jObj = JsonReader.Deserialize <Dictionary <string, object> >(json); Dictionary <string, object> data = (Dictionary <string, object>)jObj["data"]; Dictionary <string, object> stats = (Dictionary <string, object>)data["statistics"]; if (stats != null) { foreach (string key in stats.Keys) { GlobalStatistic stat = new GlobalStatistic(); stat.name = key; stat.value = System.Convert.ToInt64(stats[key]); m_stats[stat.name] = stat; } } }
protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); foreach (var p in pool) { p.Dispose(); } CountInUse = 0; CountConstructed = 0; CountAvailable = 0; GlobalStatistics.Remove(statistic); // Disallow any further Gets/Returns to adjust the statistics. statistic = null; }
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"); }); }
private void ReadAllGlobalStatsSuccess(string json, object cb) { m_mainScene.AddLog("SUCCESS"); m_mainScene.AddLogJson(json); m_mainScene.AddLog(""); JsonData jObj = JsonMapper.ToObject(json); JsonData jStats = jObj["data"]["statistics"]; IDictionary dStats = jStats as IDictionary; if (dStats != null) { foreach (string key in dStats.Keys) { GlobalStatistic stat = new GlobalStatistic(); stat.name = (string) key; JsonData value = (JsonData) dStats[key]; // silly that LitJson can't upcast an int to a long... stat.value = value.IsInt ? (int) value : (long) value; m_stats[stat.name] = stat; } } }