Guest User

Untitled

a guest
May 25th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. //Returns time taken for execution of synchronous code
  2. var syncTime = Metricity.Timings.Time(() =>
  3. {
  4. SyncMethod();
  5. });
  6.  
  7. //Returns time taken for execution of asynchronous code
  8. var asyncTime = Metricity.Timings.Time(async () =>
  9. {
  10. await ASyncMethod();
  11. });
  12.  
  13. //Returns current memory usage of application
  14. var memoryUsage = Metricity.Diagnostics.GetMemoryUsage();
  15.  
  16. //Returns current cpu usage of application
  17. var cpuUsage = Metricity.Diagnostics.GetCPUUsage();
  18.  
  19. //Returns difference in memory usage from before synchronous code execution and after
  20. var memoryChangeSync = Metricity.Diagnostics.GetMemoryChange(() =>
  21. {
  22. SyncMethod();
  23. });
  24.  
  25. //Returns difference in memory usage from before asynchronous code execution and after
  26. var memoryChangeASync = Metricity.Diagnostics.GetMemoryChange(async () =>
  27. {
  28. await ASyncMethod();
  29. });
  30.  
  31. //Logs time taken for execution of synchronous code to database
  32. Metricity.RemoteLog.Log(() =>
  33. {
  34. SyncMethod();
  35. });
  36.  
  37. //Logs time taken for execution of asynchronous code to database
  38. await Metricity.RemoteLog.Log(async () =>
  39. {
  40. await ASyncMethod();
  41. });
  42.  
  43. //Logs time taken for execution of synchronous code to cache, cache is then commited to database when CommitCache is called
  44. Metricity.RemoteLog.CacheLog(() =>
  45. {
  46. SyncMethod();
  47. });
  48.  
  49. //Logs time taken for execution of synchronous code to cache, cache is then commited to database when CommitCache is called
  50. await Metricity.RemoteLog.CacheLog(async () =>
  51. {
  52. await ASyncMethod();
  53. });
  54.  
  55. //Clears all metrics from the cache
  56. Metricity.RemoteLog.ClearCache();
  57.  
  58. //Returns the current cache
  59. var cache = Metricity.RemoteLog.GetCache();
  60.  
  61. //Commits cache to database
  62. Metricity.RemoteLog.CommitCache();
  63.  
  64. //Increments the counter by one
  65. Metricity.Counters.Increment("counter");
  66.  
  67. //Decrements the counter by one
  68. Metricity.Counters.Decrement("counter");
  69.  
  70. //Returns the count of the specified counter
  71. Metricity.Counters.GetCurrentCount("counter");
  72.  
  73. //Resets the specified counter
  74. Metricity.Counters.ClearCounter("counter");
  75.  
  76. //Resets all counters
  77. Metricity.Counters.PurgeCounters();
  78.  
  79. //Gets the percentage splits of subset counters
  80. var splits = Metricity.Counters.GetSubsetSplit("counter");
  81.  
  82. //Handles exceptions of the type that are passed in and writes an entry into HandledExceptions Table
  83. Metricity.Handlers.HandleException(() =>
  84. {
  85. ThrowException(new InvalidOperationException());
  86.  
  87. }, new List<Exception>() { new InvalidOperationException() });
Add Comment
Please, Sign In to add comment