-
Notifications
You must be signed in to change notification settings - Fork 0
/
Analytics.cs
31 lines (28 loc) · 912 Bytes
/
Analytics.cs
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
using System.Collections.Generic;
using System.Diagnostics;
namespace ActivityCollectorPlugin
{
public static class Analytics
{
private static Dictionary<string, Stopwatch> timers = new Dictionary<string, Stopwatch>();
public static void Start(string name)
{
if (ActivityCollector.Config.Data.DebugMode)
{
if (!timers.ContainsKey(name))
{
timers.Add(name, new Stopwatch());
}
timers[name].Restart();
}
}
public static void Stop(string name)
{
if (ActivityCollector.Config.Data.DebugMode && timers.ContainsKey(name))
{
timers[name].Stop();
ActivityCollector.Log.Info($"[{name}] {(timers[name].ElapsedTicks * 1000d) / Stopwatch.Frequency}ms");
}
}
}
}