Skip to content

A C# visual profiling library using Google Chrome's tracing tool

License

Notifications You must be signed in to change notification settings

pacojq/ChromeTracing.NET

Repository files navigation

Safe Creative #2004233750167

ChromeTracing.NET

A C# visual profiling library using Google Chrome's tracing tool.

Usage

Whenever you want to measure a piece of code, you just have to use ChromeTrace.Profile, and ChromeTracing.NET will do the rest.

  public static void Main(string[] args)
  {
      ChromeTrace.Init();

      using (ChromeTrace.Profile("Test"))
      {
          Random rand = new Random();
          int sleep = 1000 + rand.Next(1000);

          Console.WriteLine("Night night!");

          System.Threading.Thread.Sleep(sleep);

          Console.WriteLine($"Woke up after {sleep} ms");
      }
  }

When the application ends its execution, a trace.json file is generated. This file can be directly loaded to Google Chrome's chrome://tracing tool.

Screenshot with the result of the previous code execution displayed in the chrome://tracing tool