2 // System.Diagnostics.CounterSample.cs
5 // Jonathan Pryor (jonpryor@vt.edu)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
9 // (C) 2003 Andreas Nahr
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 namespace System.Diagnostics {
35 public struct CounterSample {
37 private long rawValue;
38 private long baseValue;
39 private long counterFrequency;
40 private long systemFrequency;
41 private long timeStamp;
42 private long timeStamp100nSec;
43 private long counterTimeStamp;
44 private PerformanceCounterType counterType;
46 public CounterSample (long rawValue,
48 long counterFrequency,
51 long timeStamp100nSec,
52 PerformanceCounterType counterType)
53 : this (rawValue, baseValue, counterFrequency,
54 systemFrequency, timeStamp, timeStamp100nSec,
59 public CounterSample (long rawValue,
61 long counterFrequency,
64 long timeStamp100nSec,
65 PerformanceCounterType counterType,
66 long counterTimeStamp)
68 this.rawValue = rawValue;
69 this.baseValue = baseValue;
70 this.counterFrequency = counterFrequency;
71 this.systemFrequency = systemFrequency;
72 this.timeStamp = timeStamp;
73 this.timeStamp100nSec = timeStamp100nSec;
74 this.counterType = counterType;
75 this.counterTimeStamp = counterTimeStamp;
78 public static CounterSample Empty = new CounterSample (
80 PerformanceCounterType.NumberOfItems32,
83 public long BaseValue {
84 get {return baseValue;}
87 public long CounterFrequency {
88 get {return counterFrequency;}
91 public long CounterTimeStamp {
92 get {return counterTimeStamp;}
95 public PerformanceCounterType CounterType {
96 get {return counterType;}
99 public long RawValue {
100 get {return rawValue;}
103 public long SystemFrequency {
104 get {return systemFrequency;}
107 public long TimeStamp {
108 get {return timeStamp;}
111 public long TimeStamp100nSec {
112 get {return timeStamp100nSec;}
115 public static float Calculate (CounterSample counterSample)
117 return CounterSampleCalculator.ComputeCounterValue (counterSample);
120 public static float Calculate (CounterSample counterSample,
121 CounterSample nextCounterSample)
123 return CounterSampleCalculator.ComputeCounterValue (counterSample, nextCounterSample);