Skip to content

Instantly share code, notes, and snippets.

@troydai
Created September 29, 2015 21:32
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 troydai/5d3d4e8143e5487d8408 to your computer and use it in GitHub Desktop.
Save troydai/5d3d4e8143e5487d8408 to your computer and use it in GitHub Desktop.
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