CounterSample.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // System.Diagnostics.CounterSample.cs
  3. //
  4. // Authors:
  5. // Jonathan Pryor ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) 2002
  9. // (C) 2003 Andreas Nahr
  10. //
  11. namespace System.Diagnostics {
  12. public struct CounterSample {
  13. private long rawValue;
  14. private long baseValue;
  15. private long counterFrequency;
  16. private long systemFrequency;
  17. private long timeStamp;
  18. private long timeStamp100nSec;
  19. private long counterTimeStamp;
  20. private PerformanceCounterType counterType;
  21. public CounterSample (long rawValue,
  22. long baseValue,
  23. long counterFrequency,
  24. long systemFrequency,
  25. long timeStamp,
  26. long timeStamp100nSec,
  27. PerformanceCounterType counterType)
  28. : this (rawValue, baseValue, counterFrequency,
  29. systemFrequency, timeStamp, timeStamp100nSec,
  30. counterType, 0)
  31. {
  32. }
  33. public CounterSample (long rawValue,
  34. long baseValue,
  35. long counterFrequency,
  36. long systemFrequency,
  37. long timeStamp,
  38. long timeStamp100nSec,
  39. PerformanceCounterType counterType,
  40. long counterTimeStamp)
  41. {
  42. this.rawValue = rawValue;
  43. this.baseValue = baseValue;
  44. this.counterFrequency = counterFrequency;
  45. this.systemFrequency = systemFrequency;
  46. this.timeStamp = timeStamp;
  47. this.timeStamp100nSec = timeStamp100nSec;
  48. this.counterType = counterType;
  49. this.counterTimeStamp = counterTimeStamp;
  50. }
  51. public static CounterSample Empty = new CounterSample (
  52. 0, 0, 0, 0, 0, 0,
  53. PerformanceCounterType.NumberOfItems32,
  54. 0);
  55. public long BaseValue {
  56. get {return baseValue;}
  57. }
  58. public long CounterFrequency {
  59. get {return counterFrequency;}
  60. }
  61. public long CounterTimeStamp {
  62. get {return counterTimeStamp;}
  63. }
  64. public PerformanceCounterType CounterType {
  65. get {return counterType;}
  66. }
  67. public long RawValue {
  68. get {return rawValue;}
  69. }
  70. public long SystemFrequency {
  71. get {return systemFrequency;}
  72. }
  73. public long TimeStamp {
  74. get {return timeStamp;}
  75. }
  76. public long TimeStamp100nSec {
  77. get {return timeStamp100nSec;}
  78. }
  79. public static float Calculate (CounterSample counterSample)
  80. {
  81. return CounterSampleCalculator.ComputeCounterValue (counterSample);
  82. }
  83. public static float Calculate (CounterSample counterSample,
  84. CounterSample nextCounterSample)
  85. {
  86. return CounterSampleCalculator.ComputeCounterValue (counterSample, nextCounterSample);
  87. }
  88. }
  89. }