Profiler.cs 864 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Diagnostics;
  5. using System.Windows.Forms;
  6. namespace FastReport.Utils
  7. {
  8. /// <summary>
  9. /// The profiler.
  10. /// </summary>
  11. public static class Profiler
  12. {
  13. private static long FMemory;
  14. private static int FTickCount;
  15. /// <summary>
  16. /// Starts the profiler.
  17. /// </summary>
  18. public static void Start()
  19. {
  20. FMemory = Process.GetCurrentProcess().PrivateMemorySize64;
  21. FTickCount = Environment.TickCount;
  22. }
  23. /// <summary>
  24. /// Finishes the profiler and displays results.
  25. /// </summary>
  26. public static void Stop()
  27. {
  28. MessageBox.Show(((Process.GetCurrentProcess().PrivateMemorySize64 - FMemory) / 1024).ToString() + " Kb" +
  29. '\r' + (Environment.TickCount - FTickCount).ToString() + " ms");
  30. }
  31. }
  32. }