Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ThreadStatic]
- //tracks number of cache hits
- internal static int m_TotalHitsForSession;
- [ThreadStatic]
- //tracks total writes
- internal static int m_TotalWritesForSession;
- [ThreadStatic]
- //tracks total reads
- internal static int m_TotalReadsForSession;
- cacheCounter1 = new PerformanceCounter();
- public class PerformanceInfo
- {
- public static PerformanceInfo Instance { get{ return _instance.Value; } }
- PerformanceCounter _totalHitsForSessionCounter = new PerformanceCounter("Total Hits",
- "Total Hits for this session",
- false);
- [ThreadStatic]
- private static readonly Lazy<PerformanceInfo> _instance =
- new Lazy<PerformanceInfo>(()=> new PerformanceInfo(), true);
- private PerformanceInfo() { }
- private int _m_TotalHitsForSession;
- private int _m_TotalWritesForSession;
- private int _m_TotalReadsForSession;
- public int m_TotalHitsForSession
- {
- get{ return _m_TotalHitsForSession;}
- set
- {
- _m_TotalHitsForSession=value;
- _totalHitsForSessionCounter.Increment();
- }
- }
- public int m_TotalWritesForSession { same as example above}
- public int m_TotalReadsForSession { same as example above }
- public override ToString()
- {
- return // detailed Performance Info
- }
- }
- PerformanceInfo.Instance.m_TotalWritesForSession++;
- Console.WriteLine("This Thread had the following Performance");
- Console.WriteLine(PerformanceInfo.Instance.ToString());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement