using System; namespace Glass.Testbed { /// /// How many garbage collections of each generation have run, for the frame readout. /// public readonly struct CollectionCounts { public readonly int Gen0; public readonly int Gen1; public readonly int Gen2; public CollectionCounts(int gen0, int gen1, int gen2) { Gen0 = gen0; Gen1 = gen1; Gen2 = gen2; } public static CollectionCounts Current() { return new CollectionCounts(GC.CollectionCount(0), GC.CollectionCount(1), GC.CollectionCount(2)); } public static CollectionCounts operator -(CollectionCounts lhs, CollectionCounts rhs) { return new CollectionCounts(lhs.Gen0 - rhs.Gen0, lhs.Gen1 - rhs.Gen1, lhs.Gen2 - rhs.Gen2); } public static CollectionCounts operator +(CollectionCounts lhs, CollectionCounts rhs) { return new CollectionCounts(lhs.Gen0 + rhs.Gen0, lhs.Gen1 + rhs.Gen1, lhs.Gen2 + rhs.Gen2); } } }