Last active
August 25, 2016 15:29
-
-
Save yasuakiohama/43c7d1348ae630e0c10f30477ddcbe0e to your computer and use it in GitHub Desktop.
Stopwatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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