Skip to content

Instantly share code, notes, and snippets.

@yasuakiohama
Last active August 25, 2016 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasuakiohama/43c7d1348ae630e0c10f30477ddcbe0e to your computer and use it in GitHub Desktop.
Save yasuakiohama/43c7d1348ae630e0c10f30477ddcbe0e to your computer and use it in GitHub Desktop.
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