Advertisement
Whiplash141

Code Profiler for Space Engineers

Oct 29th, 2016
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. //Whip's Profiler Graph Code
  2. int count = 1;
  3. int maxSeconds = 30;
  4. StringBuilder profile = new StringBuilder();
  5. bool hasWritten = false;
  6. void ProfilerGraph()
  7. {
  8.     if (count <= maxSeconds * 60)
  9.     {
  10.         double timeToRunCode = Runtime.LastRunTimeMs;
  11.  
  12.         profile.Append(timeToRunCode.ToString()).Append("\n");
  13.         count++;
  14.     }
  15.     else if (!hasWritten)
  16.     {
  17.         var screen = GridTerminalSystem.GetBlockWithName("DEBUG") as IMyTextPanel;
  18.         screen?.WritePublicText(profile.ToString());
  19.         screen?.ShowPublicTextOnScreen();
  20.         if (screen != null)
  21.             hasWritten = true;
  22.     }
  23. }
  24.  
  25. //Example usage
  26. void Main()
  27. {
  28.     ProfilerGraph();
  29.     //other shit
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement