mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Move statistics to static class
This commit is contained in:
@ -15,7 +15,7 @@ namespace osu.Game.Database
|
|||||||
/// Provides a method of working with realm objects over longer application lifetimes.
|
/// Provides a method of working with realm objects over longer application lifetimes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The underlying object type.</typeparam>
|
/// <typeparam name="T">The underlying object type.</typeparam>
|
||||||
public class RealmLive<T> : RealmLive, ILive<T> where T : RealmObject, IHasGuidPrimaryKey
|
public class RealmLive<T> : ILive<T> where T : RealmObject, IHasGuidPrimaryKey
|
||||||
{
|
{
|
||||||
public Guid ID { get; }
|
public Guid ID { get; }
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
|
|
||||||
perform(retrieveFromID(r, ID));
|
perform(retrieveFromID(r, ID));
|
||||||
USAGE_ASYNC.Value++;
|
RealmLiveStatistics.USAGE_ASYNC.Value++;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ namespace osu.Game.Database
|
|||||||
return realm.Run(r =>
|
return realm.Run(r =>
|
||||||
{
|
{
|
||||||
var returnData = perform(retrieveFromID(r, ID));
|
var returnData = perform(retrieveFromID(r, ID));
|
||||||
USAGE_ASYNC.Value++;
|
RealmLiveStatistics.USAGE_ASYNC.Value++;
|
||||||
|
|
||||||
if (returnData is RealmObjectBase realmObject && realmObject.IsManaged)
|
if (returnData is RealmObjectBase realmObject && realmObject.IsManaged)
|
||||||
throw new InvalidOperationException(@$"Managed realm objects should not exit the scope of {nameof(PerformRead)}.");
|
throw new InvalidOperationException(@$"Managed realm objects should not exit the scope of {nameof(PerformRead)}.");
|
||||||
@ -111,7 +111,7 @@ namespace osu.Game.Database
|
|||||||
var transaction = t.Realm.BeginWrite();
|
var transaction = t.Realm.BeginWrite();
|
||||||
perform(t);
|
perform(t);
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
WRITES.Value++;
|
RealmLiveStatistics.WRITES.Value++;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,13 +136,13 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
if (dataIsFromUpdateThread && !data.Realm.IsClosed)
|
if (dataIsFromUpdateThread && !data.Realm.IsClosed)
|
||||||
{
|
{
|
||||||
USAGE_UPDATE_IMMEDIATE.Value++;
|
RealmLiveStatistics.USAGE_UPDATE_IMMEDIATE.Value++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataIsFromUpdateThread = true;
|
dataIsFromUpdateThread = true;
|
||||||
data = retrieveFromID(realm.Realm, ID);
|
data = retrieveFromID(realm.Realm, ID);
|
||||||
USAGE_UPDATE_REFETCH.Value++;
|
RealmLiveStatistics.USAGE_UPDATE_REFETCH.Value++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private T retrieveFromID(Realm realm, Guid id)
|
private T retrieveFromID(Realm realm, Guid id)
|
||||||
@ -166,11 +166,11 @@ namespace osu.Game.Database
|
|||||||
public override string ToString() => PerformRead(i => i.ToString());
|
public override string ToString() => PerformRead(i => i.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RealmLive
|
internal static class RealmLiveStatistics
|
||||||
{
|
{
|
||||||
protected static readonly GlobalStatistic<int> WRITES = GlobalStatistics.Get<int>(@"Realm", @"Live writes");
|
public static readonly GlobalStatistic<int> WRITES = GlobalStatistics.Get<int>(@"Realm", @"Live writes");
|
||||||
protected static readonly GlobalStatistic<int> USAGE_UPDATE_IMMEDIATE = GlobalStatistics.Get<int>(@"Realm", @"Live update read (fast)");
|
public static readonly GlobalStatistic<int> USAGE_UPDATE_IMMEDIATE = GlobalStatistics.Get<int>(@"Realm", @"Live update read (fast)");
|
||||||
protected static readonly GlobalStatistic<int> USAGE_UPDATE_REFETCH = GlobalStatistics.Get<int>(@"Realm", @"Live update read (slow)");
|
public static readonly GlobalStatistic<int> USAGE_UPDATE_REFETCH = GlobalStatistics.Get<int>(@"Realm", @"Live update read (slow)");
|
||||||
protected static readonly GlobalStatistic<int> USAGE_ASYNC = GlobalStatistics.Get<int>(@"Realm", @"Live async read");
|
public static readonly GlobalStatistic<int> USAGE_ASYNC = GlobalStatistics.Get<int>(@"Realm", @"Live async read");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user