Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Monitoring / system / Diagnosticts / CounterSample.cs / 1305376 / CounterSample.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Diagnostics {
using System.Diagnostics;
using System;
///
/// A struct holding the raw data for a performance counter.
///
public struct CounterSample {
private long rawValue;
private long baseValue;
private long timeStamp;
private long counterFrequency;
private PerformanceCounterType counterType;
private long timeStamp100nSec;
private long systemFrequency;
private long counterTimeStamp;
// Dummy holder for an empty sample
///
/// [To be supplied.]
///
public static CounterSample Empty = new CounterSample(0, 0, 0, 0, 0, 0, PerformanceCounterType.NumberOfItems32);
///
/// [To be supplied.]
///
public CounterSample(long rawValue, long baseValue, long counterFrequency, long systemFrequency, long timeStamp, long timeStamp100nSec, PerformanceCounterType counterType) {
this.rawValue = rawValue;
this.baseValue = baseValue;
this.timeStamp = timeStamp;
this.counterFrequency = counterFrequency;
this.counterType = counterType;
this.timeStamp100nSec = timeStamp100nSec;
this.systemFrequency = systemFrequency;
this.counterTimeStamp = 0;
}
///
/// [To be supplied.]
///
public CounterSample(long rawValue, long baseValue, long counterFrequency, long systemFrequency, long timeStamp, long timeStamp100nSec, PerformanceCounterType counterType, long counterTimeStamp) {
this.rawValue = rawValue;
this.baseValue = baseValue;
this.timeStamp = timeStamp;
this.counterFrequency = counterFrequency;
this.counterType = counterType;
this.timeStamp100nSec = timeStamp100nSec;
this.systemFrequency = systemFrequency;
this.counterTimeStamp = counterTimeStamp;
}
///
/// Raw value of the counter.
///
public long RawValue {
get {
return this.rawValue;
}
}
internal ulong UnsignedRawValue {
get {
return (ulong)this.rawValue;
}
}
///
/// Optional base raw value for the counter (only used if multiple counter based).
///
public long BaseValue {
get {
return this.baseValue;
}
}
///
/// Raw system frequency
///
public long SystemFrequency {
get {
return this.systemFrequency;
}
}
///
/// Raw counter frequency
///
public long CounterFrequency {
get {
return this.counterFrequency;
}
}
///
/// Raw counter frequency
///
public long CounterTimeStamp {
get {
return this.counterTimeStamp;
}
}
///
/// Raw timestamp
///
public long TimeStamp {
get {
return this.timeStamp;
}
}
///
/// Raw high fidelity timestamp
///
public long TimeStamp100nSec {
get {
return this.timeStamp100nSec;
}
}
///
/// Counter type
///
public PerformanceCounterType CounterType {
get {
return this.counterType;
}
}
///
/// Static functions to calculate the performance value off the sample
///
public static float Calculate(CounterSample counterSample) {
return CounterSampleCalculator.ComputeCounterValue(counterSample);
}
///
/// Static functions to calculate the performance value off the samples
///
public static float Calculate(CounterSample counterSample, CounterSample nextCounterSample) {
return CounterSampleCalculator.ComputeCounterValue(counterSample, nextCounterSample);
}
public override bool Equals(Object o) {
return ( o is CounterSample) && Equals((CounterSample)o);
}
public bool Equals(CounterSample sample) {
return (rawValue == sample.rawValue) &&
(baseValue == sample.baseValue) &&
(timeStamp == sample.timeStamp) &&
(counterFrequency == sample.counterFrequency) &&
(counterType == sample.counterType) &&
(timeStamp100nSec == sample.timeStamp100nSec) &&
(systemFrequency == sample.systemFrequency) &&
(counterTimeStamp == sample.counterTimeStamp);
}
public override int GetHashCode() {
return rawValue.GetHashCode();
}
public static bool operator ==(CounterSample a, CounterSample b) {
return a.Equals(b);
}
public static bool operator !=(CounterSample a, CounterSample b) {
return !(a.Equals(b));
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Diagnostics {
using System.Diagnostics;
using System;
///
/// A struct holding the raw data for a performance counter.
///
public struct CounterSample {
private long rawValue;
private long baseValue;
private long timeStamp;
private long counterFrequency;
private PerformanceCounterType counterType;
private long timeStamp100nSec;
private long systemFrequency;
private long counterTimeStamp;
// Dummy holder for an empty sample
///
/// [To be supplied.]
///
public static CounterSample Empty = new CounterSample(0, 0, 0, 0, 0, 0, PerformanceCounterType.NumberOfItems32);
///
/// [To be supplied.]
///
public CounterSample(long rawValue, long baseValue, long counterFrequency, long systemFrequency, long timeStamp, long timeStamp100nSec, PerformanceCounterType counterType) {
this.rawValue = rawValue;
this.baseValue = baseValue;
this.timeStamp = timeStamp;
this.counterFrequency = counterFrequency;
this.counterType = counterType;
this.timeStamp100nSec = timeStamp100nSec;
this.systemFrequency = systemFrequency;
this.counterTimeStamp = 0;
}
///
/// [To be supplied.]
///
public CounterSample(long rawValue, long baseValue, long counterFrequency, long systemFrequency, long timeStamp, long timeStamp100nSec, PerformanceCounterType counterType, long counterTimeStamp) {
this.rawValue = rawValue;
this.baseValue = baseValue;
this.timeStamp = timeStamp;
this.counterFrequency = counterFrequency;
this.counterType = counterType;
this.timeStamp100nSec = timeStamp100nSec;
this.systemFrequency = systemFrequency;
this.counterTimeStamp = counterTimeStamp;
}
///
/// Raw value of the counter.
///
public long RawValue {
get {
return this.rawValue;
}
}
internal ulong UnsignedRawValue {
get {
return (ulong)this.rawValue;
}
}
///
/// Optional base raw value for the counter (only used if multiple counter based).
///
public long BaseValue {
get {
return this.baseValue;
}
}
///
/// Raw system frequency
///
public long SystemFrequency {
get {
return this.systemFrequency;
}
}
///
/// Raw counter frequency
///
public long CounterFrequency {
get {
return this.counterFrequency;
}
}
///
/// Raw counter frequency
///
public long CounterTimeStamp {
get {
return this.counterTimeStamp;
}
}
///
/// Raw timestamp
///
public long TimeStamp {
get {
return this.timeStamp;
}
}
///
/// Raw high fidelity timestamp
///
public long TimeStamp100nSec {
get {
return this.timeStamp100nSec;
}
}
///
/// Counter type
///
public PerformanceCounterType CounterType {
get {
return this.counterType;
}
}
///
/// Static functions to calculate the performance value off the sample
///
public static float Calculate(CounterSample counterSample) {
return CounterSampleCalculator.ComputeCounterValue(counterSample);
}
///
/// Static functions to calculate the performance value off the samples
///
public static float Calculate(CounterSample counterSample, CounterSample nextCounterSample) {
return CounterSampleCalculator.ComputeCounterValue(counterSample, nextCounterSample);
}
public override bool Equals(Object o) {
return ( o is CounterSample) && Equals((CounterSample)o);
}
public bool Equals(CounterSample sample) {
return (rawValue == sample.rawValue) &&
(baseValue == sample.baseValue) &&
(timeStamp == sample.timeStamp) &&
(counterFrequency == sample.counterFrequency) &&
(counterType == sample.counterType) &&
(timeStamp100nSec == sample.timeStamp100nSec) &&
(systemFrequency == sample.systemFrequency) &&
(counterTimeStamp == sample.counterTimeStamp);
}
public override int GetHashCode() {
return rawValue.GetHashCode();
}
public static bool operator ==(CounterSample a, CounterSample b) {
return a.Equals(b);
}
public static bool operator !=(CounterSample a, CounterSample b) {
return !(a.Equals(b));
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TableLayoutStyle.cs
- Page.cs
- FtpCachePolicyElement.cs
- BitmapEffectCollection.cs
- TreeBuilderBamlTranslator.cs
- BatchParser.cs
- TiffBitmapEncoder.cs
- SrgsElementList.cs
- Codec.cs
- DrawingServices.cs
- ContextActivityUtils.cs
- PartialArray.cs
- ColumnTypeConverter.cs
- SqlDataSourceQueryEditorForm.cs
- RegexRunner.cs
- SingleAnimation.cs
- AuthenticationManager.cs
- BindingManagerDataErrorEventArgs.cs
- SqlDataSourceCommandEventArgs.cs
- PersonalizableTypeEntry.cs
- BitConverter.cs
- DrawingImage.cs
- PropertyConverter.cs
- FontStretch.cs
- AvtEvent.cs
- ElapsedEventArgs.cs
- TargetException.cs
- ComplexLine.cs
- TextDecoration.cs
- _CookieModule.cs
- GridViewRowCollection.cs
- BasicExpandProvider.cs
- HtmlContainerControl.cs
- Transform3DGroup.cs
- AutomationProperty.cs
- DriveNotFoundException.cs
- TraceLog.cs
- XmlSchemaFacet.cs
- XomlCompilerResults.cs
- XamlClipboardData.cs
- Assert.cs
- EventData.cs
- HandleTable.cs
- LinqDataSourceValidationException.cs
- DecoderFallback.cs
- XmlFileEditor.cs
- precedingquery.cs
- Point3D.cs
- DnsEndPoint.cs
- AutomationElementIdentifiers.cs
- HotSpot.cs
- Point3DCollection.cs
- EmbeddedMailObject.cs
- InputLanguageEventArgs.cs
- RoutedEventValueSerializer.cs
- ProviderMetadata.cs
- BinHexEncoder.cs
- NamespaceTable.cs
- StaticFileHandler.cs
- ItemDragEvent.cs
- X509ChainElement.cs
- HtmlTitle.cs
- AlternateViewCollection.cs
- ConditionalAttribute.cs
- DiffuseMaterial.cs
- SettingsPropertyCollection.cs
- SoapSchemaMember.cs
- Int32Animation.cs
- SqlFunctionAttribute.cs
- AdapterSwitches.cs
- TextBounds.cs
- PenThread.cs
- basenumberconverter.cs
- EdmFunctions.cs
- GenericIdentity.cs
- WebPartExportVerb.cs
- activationcontext.cs
- CompositionTarget.cs
- IteratorFilter.cs
- XmlNamespaceMappingCollection.cs
- HttpSysSettings.cs
- DrawingState.cs
- TypeConverterValueSerializer.cs
- Parser.cs
- XmlSerializerAssemblyAttribute.cs
- HttpCookieCollection.cs
- RowVisual.cs
- WinInet.cs
- NotifyParentPropertyAttribute.cs
- Thickness.cs
- HitTestWithGeometryDrawingContextWalker.cs
- TemplateParser.cs
- CodeLabeledStatement.cs
- TextEffectResolver.cs
- DirectoryInfo.cs
- ApplicationSecurityManager.cs
- UpdateCommand.cs
- HttpException.cs
- Bezier.cs
- BooleanAnimationBase.cs