Last active
July 12, 2018 15:17
-
-
Save bernhard-hofmann/956893 to your computer and use it in GitHub Desktop.
C# snippet to surround code with a stopwatch
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
<?xml version="1.0" encoding="utf-8" ?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<Title>Stopwatch</Title> | |
<Shortcut>SW</Shortcut> | |
<Description>Code snippet for Stopwatch</Description> | |
<Author>Bernhard Hofmann</Author> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
<SnippetType>SurroundsWith</SnippetType> | |
</SnippetTypes> | |
</Header> | |
<Snippet> | |
<Code Language="csharp"><![CDATA[var tacho = System.Diagnostics.Stopwatch.StartNew(); | |
$selected$ $end$ | |
tacho.Stop(); | |
System.Diagnostics.Trace.WriteLine(string.Format("Elapsed: {0}", tacho.Elapsed)); | |
]]> | |
</Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
Thanks Andrei, I've made that change. 5 month turnaround - not bad eh? :P
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great. Thanks. You should use the static method Stopwatch.StartNew() to both allocate a new stopwatch and start it in a single line