summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/PerformanceMonitoring/AlertContext.cs
blob: 01197f747af902d713147d469b8eee435904c3f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
namespace StardewModdingAPI.Framework.PerformanceMonitoring
{
    /// <summary>The context for an alert.</summary>
    internal struct AlertContext
    {
        /*********
        ** Accessors
        *********/
        /// <summary>The source which triggered the alert.</summary>
        public string Source { get; }

        /// <summary>The elapsed milliseconds.</summary>
        public double Elapsed { get; }


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="source">The source which triggered the alert.</param>
        /// <param name="elapsed">The elapsed milliseconds.</param>
        public AlertContext(string source, double elapsed)
        {
            this.Source = source;
            this.Elapsed = elapsed;
        }

        /// <summary>Get a human-readable text form of this instance.</summary>
        public override string ToString()
        {
            return $"{this.Source}: {this.Elapsed:F2}ms";
        }
    }
}