Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Services / Monitoring / system / Diagnosticts / CounterSample.cs / 1 / 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
- Win32Exception.cs
- PerformanceCounterPermissionEntry.cs
- IsolatedStorageFileStream.cs
- ListDictionaryInternal.cs
- TreeIterator.cs
- XsdValidatingReader.cs
- OleDbSchemaGuid.cs
- AnnotationHighlightLayer.cs
- CalendarDesigner.cs
- WebPart.cs
- BindingOperations.cs
- ProgressBar.cs
- TripleDESCryptoServiceProvider.cs
- QilTypeChecker.cs
- ColumnBinding.cs
- InternalConfigHost.cs
- HTTPNotFoundHandler.cs
- EventEntry.cs
- safex509handles.cs
- StreamReader.cs
- DtdParser.cs
- WebPartConnectionsDisconnectVerb.cs
- Int64Animation.cs
- Geometry3D.cs
- OAVariantLib.cs
- ObjectQueryProvider.cs
- XmlWellformedWriter.cs
- WindowsScrollBar.cs
- ContainerCodeDomSerializer.cs
- PageWrapper.cs
- Geometry.cs
- LogAppendAsyncResult.cs
- HScrollBar.cs
- SafeThreadHandle.cs
- _HeaderInfo.cs
- ApplicationSettingsBase.cs
- _ContextAwareResult.cs
- DoubleCollection.cs
- FormClosingEvent.cs
- Guid.cs
- GreenMethods.cs
- FileSystemWatcher.cs
- ProfileGroupSettings.cs
- TextUtf8RawTextWriter.cs
- PageAsyncTaskManager.cs
- CryptoStream.cs
- XslAstAnalyzer.cs
- AsymmetricSignatureFormatter.cs
- TypeConverterHelper.cs
- ILGenerator.cs
- DataGridViewImageColumn.cs
- NullableBoolConverter.cs
- GrammarBuilderRuleRef.cs
- Literal.cs
- Compiler.cs
- DataGridColumnStyleMappingNameEditor.cs
- FileIOPermission.cs
- SHA512CryptoServiceProvider.cs
- PkcsMisc.cs
- MemberMemberBinding.cs
- Ray3DHitTestResult.cs
- IsolatedStorageFile.cs
- AmbientValueAttribute.cs
- Component.cs
- PlacementWorkspace.cs
- SqlServices.cs
- OutputWindow.cs
- HyperLinkField.cs
- ExecutionEngineException.cs
- DocumentGridContextMenu.cs
- RegexTree.cs
- CngProperty.cs
- BinarySecretKeyIdentifierClause.cs
- LassoSelectionBehavior.cs
- AnnotationService.cs
- WindowsIdentity.cs
- RequestCacheManager.cs
- Polyline.cs
- Compiler.cs
- BuildProvider.cs
- ResourceManagerWrapper.cs
- FixedHyperLink.cs
- TextTreeInsertElementUndoUnit.cs
- CommandHelpers.cs
- ApplicationSettingsBase.cs
- Transactions.cs
- FileDialogCustomPlacesCollection.cs
- SapiGrammar.cs
- Calendar.cs
- BoolExpr.cs
- ColorKeyFrameCollection.cs
- MachineSettingsSection.cs
- DashStyle.cs
- EventDriven.cs
- PolicyException.cs
- PropertyGridDesigner.cs
- ManifestResourceInfo.cs
- XmlDataProvider.cs
- EntityReference.cs
- CreateParams.cs