New test.
[mono.git] / mcs / class / System / System.Diagnostics / CounterSample.cs
1 //
2 // System.Diagnostics.CounterSample.cs
3 //
4 // Authors:
5 //   Jonathan Pryor (jonpryor@vt.edu)
6 //   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 //
8 // (C) 2002
9 // (C) 2003 Andreas Nahr
10 //
11
12 //
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:
20 // 
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 // 
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.
31 //
32
33 namespace System.Diagnostics {
34
35         public struct CounterSample {
36                 
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;
45
46                 public CounterSample (long rawValue, 
47                         long baseValue, 
48                         long counterFrequency, 
49                         long systemFrequency, 
50                         long timeStamp, 
51                         long timeStamp100nSec, 
52                         PerformanceCounterType counterType)
53                         : this (rawValue, baseValue, counterFrequency, 
54                                 systemFrequency, timeStamp, timeStamp100nSec, 
55                                 counterType, 0)
56                 {
57                 }
58
59                 public CounterSample (long rawValue, 
60                         long baseValue, 
61                         long counterFrequency, 
62                         long systemFrequency, 
63                         long timeStamp, 
64                         long timeStamp100nSec, 
65                         PerformanceCounterType counterType, 
66                         long counterTimeStamp)
67                 {
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;
76                 }
77
78                 public static CounterSample Empty = new CounterSample (
79                         0, 0, 0, 0, 0, 0, 
80                         PerformanceCounterType.NumberOfItems32, 
81                         0);
82
83                 public long BaseValue {
84                         get {return baseValue;}
85                 }
86
87                 public long CounterFrequency {
88                         get {return counterFrequency;}
89                 }
90
91                 public long CounterTimeStamp {
92                         get {return counterTimeStamp;}
93                 }
94
95                 public PerformanceCounterType CounterType {
96                         get {return counterType;}
97                 }
98
99                 public long RawValue {
100                         get {return rawValue;}
101                 }
102
103                 public long SystemFrequency {
104                         get {return systemFrequency;}
105                 }
106
107                 public long TimeStamp {
108                         get {return timeStamp;}
109                 }
110
111                 public long TimeStamp100nSec {
112                         get {return timeStamp100nSec;}
113                 }
114
115                 public static float Calculate (CounterSample counterSample)
116                 {
117                         return CounterSampleCalculator.ComputeCounterValue (counterSample);
118                 }
119
120                 public static float Calculate (CounterSample counterSample,
121                         CounterSample nextCounterSample)
122                 {
123                         return CounterSampleCalculator.ComputeCounterValue (counterSample, nextCounterSample);
124                 }
125         }
126 }
127