/// <summary> /// Increments a performance counter for average Hive query duration, if this instance has been given /// a reference to a performance counter object. /// </summary> /// <param name="ticks">The ticks.</param> /// <remarks>Performance counting is optional and so this instance may have been instantiated without a reference to /// a performance counter proxy, in which case this method fails silently.</remarks> private void CountResolveProviderMap(long ticks) { if (PerfCounterManager != null) { PerfCounterManager.IncrementDuration(HivePreDefinedCounters.AverageHiveQueryDuration, HivePreDefinedCounters.AverageHiveQueryDurationBase, ticks); } }
/// <summary> /// Default constructor to initialize /// an instance of the cache. /// </summary> public XmlSerializerCache() { SyncRoot = new object(); #if USE_PERF_COUNTER stats = new PerfCounterManager(); #endif //Serializers = new Dictionary<string, System.Xml.Serialization.XmlSerializer>(); Serializers = new System.Collections.Generic.Dictionary <string, XmlSerializer>(); }
public void InstanceCount() { string instanceName = GetCounterInstanceName(0); using (PerfCounterManager manager = new PerfCounterManager()) { using (PerformanceCounter counter = new PerformanceCounter(CATEGORY , CACHED_INSTANCES_NAME , instanceName , true)) { Assert.IsNotNull(counter); Assert.AreEqual(0.0, (decimal)counter.NextValue()); manager.IncrementInstanceCount(); Assert.AreEqual(1.0, (decimal)counter.NextValue()); } } using (PerformanceCounter counter = new PerformanceCounter(CATEGORY , CACHED_INSTANCES_NAME , instanceName , true)) { try { long l = counter.RawValue; } catch (InvalidOperationException) { // the counter instance went away when we // disposed the manager object. // This exception is what we wanted. } } }