using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace MyDownloader.Core.Instrumentation
{
///
/// MyStopwatch is a debbuging tool to count the amout of time used by an operation.
///
public class MyStopwatch : IDisposable
{
#region Fields
private Stopwatch internalStopwatch;
private string name;
#endregion
#region Constructor
///
/// Initializes the MyStopwatch
///
/// The name of MyStopwatch
public MyStopwatch(string name)
{
#if DEBUG
this.name = name;
internalStopwatch = new Stopwatch();
internalStopwatch.Start();
#endif
}
#endregion
#region Methods
///
/// Disposes the MyStopwatch and writes into debug the amount of time used on the operation.
///
public void Dispose()
{
#if DEBUG
internalStopwatch.Stop();
Debug.WriteLine(name + ": " + internalStopwatch.Elapsed);
#endif
}
#endregion
}
}