Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 28 additions & 126 deletions src/Microsoft.PowerShell.Commands.Diagnostics/CounterSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,127 +27,43 @@ internal PerformanceCounterSample(string path,
UInt64 timeStamp100nSec,
UInt32 status)
{
_path = path;
_instanceName = instanceName;
_cookedValue = cookedValue;
_rawValue = rawValue;
_secondValue = secondValue;
_multiCount = multiCount;
_counterType = counterType;
_defaultScale = defaultScale;
_timeBase = timeBase;
_timeStamp = timeStamp;
_timeStamp100nSec = timeStamp100nSec;
_status = status;
Path = path;
InstanceName = instanceName;
CookedValue = cookedValue;
RawValue = rawValue;
SecondValue = secondValue;
MultipleCount = multiCount;
CounterType = counterType;
DefaultScale = defaultScale;
TimeBase = timeBase;
Timestamp = timeStamp;
Timestamp100NSec = timeStamp100nSec;
Status = status;
}

public string Path
{
get { return _path; }

set { _path = value; }
}

private string _path = string.Empty;

public string InstanceName
{
get { return _instanceName; }

set { _instanceName = value; }
}

private string _instanceName = string.Empty;

public double CookedValue
{
get { return _cookedValue; }

set { _cookedValue = value; }
}

private double _cookedValue = 0;

public UInt64 RawValue
{
get { return _rawValue; }

set { _rawValue = value; }
}

private UInt64 _rawValue = 0;

public UInt64 SecondValue
{
get { return _secondValue; }

set { _secondValue = value; }
}

private UInt64 _secondValue = 0;

public uint MultipleCount
{
get { return _multiCount; }

set { _multiCount = value; }
}
public string Path { get; set; } = string.Empty;

private uint _multiCount = 0;
public string InstanceName { get; set; } = string.Empty;

public PerformanceCounterType CounterType
{
get { return _counterType; }

set { _counterType = value; }
}

private PerformanceCounterType _counterType = 0;

public DateTime Timestamp
{
get { return _timeStamp; }

set { _timeStamp = value; }
}

private DateTime _timeStamp = DateTime.MinValue;

public UInt64 Timestamp100NSec
{
get { return _timeStamp100nSec; }

set { _timeStamp100nSec = value; }
}

private UInt64 _timeStamp100nSec = 0;
public double CookedValue { get; set; }

public UInt32 Status
{
get { return _status; }
public UInt64 RawValue { get; set; }

set { _status = value; }
}
public UInt64 SecondValue { get; set; }

private UInt32 _status = 0;
public uint MultipleCount { get; set; }

public UInt32 DefaultScale
{
get { return _defaultScale; }
public PerformanceCounterType CounterType { get; set; }

set { _defaultScale = value; }
}
public DateTime Timestamp { get; set; } = DateTime.MinValue;

private UInt32 _defaultScale = 0;
public UInt64 Timestamp100NSec { get; set; }

public UInt64 TimeBase
{
get { return _timeBase; }
public UInt32 Status { get; set; }

set { _timeBase = value; }
}
public UInt32 DefaultScale { get; set; }

private UInt64 _timeBase = 0;
public UInt64 TimeBase { get; set; }
}

public class PerformanceCounterSampleSet
Expand All @@ -161,31 +77,17 @@ internal PerformanceCounterSampleSet(DateTime timeStamp,
PerformanceCounterSample[] counterSamples,
bool firstSet) : this()
{
_timeStamp = timeStamp;
_counterSamples = counterSamples;
}

public DateTime Timestamp
{
get { return _timeStamp; }

set { _timeStamp = value; }
Timestamp = timeStamp;
CounterSamples = counterSamples;
}

private DateTime _timeStamp = DateTime.MinValue;
public DateTime Timestamp { get; set; } = DateTime.MinValue;

[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays",
Scope = "member",
Target = "Microsoft.PowerShell.Commands.GetCounter.PerformanceCounterSample.CounterSamples",
Justification = "A string[] is required here because that is the type Powershell supports")]
public PerformanceCounterSample[] CounterSamples
{
get { return _counterSamples; }

set { _counterSamples = value; }
}

private PerformanceCounterSample[] _counterSamples = null;
public PerformanceCounterSample[] CounterSamples { get; set; }

private readonly ResourceManager _resourceMgr = null;
}
Expand Down
82 changes: 21 additions & 61 deletions src/Microsoft.PowerShell.Commands.Diagnostics/CounterSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,74 +16,34 @@ internal CounterSet(string setName,
string setHelp,
ref Dictionary<string, string[]> counterInstanceMapping)
{
_counterSetName = setName;
CounterSetName = setName;
if (machineName == null || machineName.Length == 0)
{
machineName = ".";
}
else
{
_machineName = machineName;
if (!_machineName.StartsWith(@"\\", StringComparison.OrdinalIgnoreCase))
MachineName = machineName;
if (!MachineName.StartsWith(@"\\", StringComparison.OrdinalIgnoreCase))
{
_machineName = @"\\" + _machineName;
MachineName = @"\\" + MachineName;
}
}

_counterSetType = categoryType;
_description = setHelp;
_counterInstanceMapping = counterInstanceMapping;
CounterSetType = categoryType;
Description = setHelp;
CounterInstanceMapping = counterInstanceMapping;
}

public string CounterSetName
{
get
{
return _counterSetName;
}
}

private readonly string _counterSetName = string.Empty;

public string MachineName
{
get
{
return _machineName;
}
}

private readonly string _machineName = ".";

public PerformanceCounterCategoryType CounterSetType
{
get
{
return _counterSetType;
}
}
public string CounterSetName { get; } = string.Empty;

private readonly PerformanceCounterCategoryType _counterSetType;
public string MachineName { get; } = ".";

public string Description
{
get
{
return _description;
}
}

private readonly string _description = string.Empty;
public PerformanceCounterCategoryType CounterSetType { get; }

internal Dictionary<string, string[]> CounterInstanceMapping
{
get
{
return _counterInstanceMapping;
}
}
public string Description { get; } = string.Empty;

private readonly Dictionary<string, string[]> _counterInstanceMapping;
internal Dictionary<string, string[]> CounterInstanceMapping { get; }

public StringCollection Paths
{
Expand All @@ -95,15 +55,15 @@ public StringCollection Paths
string path;
if (CounterInstanceMapping[counterName].Length != 0)
{
path = (_machineName == ".") ?
("\\" + _counterSetName + "(*)\\" + counterName) :
(_machineName + "\\" + _counterSetName + "(*)\\" + counterName);
path = (MachineName == ".") ?
("\\" + CounterSetName + "(*)\\" + counterName) :
(MachineName + "\\" + CounterSetName + "(*)\\" + counterName);
}
else
{
path = (_machineName == ".") ?
("\\" + _counterSetName + "\\" + counterName) :
(_machineName + "\\" + _counterSetName + "\\" + counterName);
path = (MachineName == ".") ?
("\\" + CounterSetName + "\\" + counterName) :
(MachineName + "\\" + CounterSetName + "\\" + counterName);
}

retColl.Add(path);
Expand All @@ -122,9 +82,9 @@ public StringCollection PathsWithInstances
{
foreach (string instanceName in CounterInstanceMapping[counterName])
{
string path = (_machineName == ".") ?
("\\" + _counterSetName + "(" + instanceName + ")\\" + counterName) :
(_machineName + "\\" + _counterSetName + "(" + instanceName + ")\\" + counterName);
string path = (MachineName == ".") ?
("\\" + CounterSetName + "(" + instanceName + ")\\" + counterName) :
(MachineName + "\\" + CounterSetName + "(" + instanceName + ")\\" + counterName);
retColl.Add(path);
}
}
Expand Down
Loading