Created
September 11, 2014 14:31
-
-
Save jeffijoe/f4b36b37589931a807b8 to your computer and use it in GitHub Desktop.
C# "Benchmark" helper.
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
// Benchmark.cs | |
// Author: Jeff Hansen <jeff@memberlink.com> | |
using System; | |
using System.Diagnostics; | |
namespace Sharp2D.Tests.EngineTests.TestHelpers | |
{ | |
/// <summary> | |
/// Benchmark helper. | |
/// </summary> | |
public static class Benchmark | |
{ | |
private static Stopwatch _sw = new Stopwatch(); | |
/// <summary> | |
/// Starts the benchmark, and writes the passed message to the console. | |
/// </summary> | |
/// <param name="messageForConsole">The message for console.</param> | |
public static void Start(string messageForConsole) | |
{ | |
Console.Write(messageForConsole); | |
_sw.Restart(); | |
} | |
/// <summary> | |
/// Ends the benchmark and prints the elapsed time to the console. | |
/// </summary> | |
public static void End() | |
{ | |
_sw.Stop(); | |
Console.WriteLine(" {0}ms", _sw.ElapsedMilliseconds); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment