Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Stopwatch.cs
using System;
using UnityEngine;
public static class Stopwatch
{
private static System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
public static void Elapsed(Action action)
{
Elapsed(action.Method.Name, action);
}
public static void Elapsed(string text ,Action action)
{
stopwatch.Start();
action();
string elapsed = stopwatch.Elapsed.ToString();
Debug.Log(string.Format("{0}[{1}] {2}", typeof(Stopwatch).Name, text ,elapsed));
stopwatch.Stop();
stopwatch.Reset();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment