PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/base/Kernel/Singularity/PerfCounters.cs

#
C# | 93 lines | 68 code | 15 blank | 10 comment | 0 complexity | 26ab01fe20ee8808024fa846e2a34028 MD5 | raw file
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft Research Singularity
  4. //
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. //
  7. // File: PerfCounters.cs
  8. //
  9. // Note:
  10. //
  11. using System;
  12. using System.GCs;
  13. using System.Collections;
  14. using System.Diagnostics;
  15. using System.Runtime.CompilerServices;
  16. using System.Runtime.InteropServices;
  17. using System.Threading;
  18. using Microsoft.Singularity;
  19. using Microsoft.Singularity.Io;
  20. using Microsoft.Singularity.Xml;
  21. using Microsoft.Singularity.Loader;
  22. using Microsoft.Singularity.Memory;
  23. using Microsoft.Singularity.Directory;
  24. using Microsoft.Singularity.Scheduling;
  25. using Microsoft.Singularity.V1.Threads;
  26. using Microsoft.Singularity.V1.Services;
  27. using Microsoft.Singularity.Security;
  28. namespace Microsoft.Singularity
  29. {
  30. [CLSCompliant(false)]
  31. public class PerfCounters
  32. {
  33. private static long threadsCreated;
  34. private static long bytesSent;
  35. private static long msgsSent;
  36. private static long channelsCreated;
  37. public static void Initialize() {
  38. threadsCreated = 0;
  39. bytesSent = 0;
  40. msgsSent = 0;
  41. channelsCreated = 0;
  42. }
  43. public static void IncrementChannelsCreated() {
  44. Interlocked.Increment(ref channelsCreated);
  45. }
  46. public static long ChannelsCreated {
  47. get {
  48. return channelsCreated;
  49. }
  50. }
  51. public static void IncrementThreadsCreated() {
  52. Interlocked.Increment(ref threadsCreated);
  53. }
  54. public static long ThreadsCreated {
  55. get {
  56. return threadsCreated;
  57. }
  58. }
  59. public static void AddBytesSent(long bytes) {
  60. bool iflag = Processor.DisableInterrupts();
  61. bytesSent += bytes;
  62. Processor.RestoreInterrupts(iflag);
  63. }
  64. public static long BytesSent {
  65. get {
  66. return bytesSent;
  67. }
  68. }
  69. public static void IncrementMsgsSent() {
  70. Interlocked.Increment(ref msgsSent);
  71. }
  72. public static long MsgsSent {
  73. get {
  74. return msgsSent;
  75. }
  76. }
  77. }
  78. }