Created
September 29, 2015 21:32
-
-
Save troydai/5d3d4e8143e5487d8408 to your computer and use it in GitHub Desktop.
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 System.IO; | |
namespace Microsoft.Dnx.Testing | |
{ | |
public class TimeLogger | |
{ | |
private readonly string _file; | |
private TimeLogger() | |
{ | |
_file = $@"C:\code\playground\wow\time{DateTime.Now.ToString("yyyyMMdd-hhmmss")}.log"; | |
using (File.CreateText(_file)) ; | |
} | |
public static TimeLogger Instance = new TimeLogger(); | |
public void Log(DateTime beginning, string category) | |
{ | |
Log(beginning, category, null); | |
} | |
public void Log(DateTime beginning, string category, string remark) | |
{ | |
var elapsed = (DateTime.Now - beginning).TotalMilliseconds; | |
File.AppendAllLines(_file, new string[] { $"{elapsed}, {category}, {remark ?? string.Empty}" }); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment