Created
January 4, 2017 15:22
-
-
Save jkotas/132e2b8fbe29b69622b322b806635504 to your computer and use it in GitHub Desktop.
Path normalization perf test
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.Text; | |
using System.IO; | |
class My { | |
static void Test(string name, string path) | |
{ | |
int start = Environment.TickCount; | |
int count = 200000000 / path.Length; | |
for (int i = 0; i < count; i++) | |
Path.GetFullPath(path); | |
int end = Environment.TickCount; | |
Console.Write(name); | |
Console.Write(" "); | |
Console.WriteLine((end-start).ToString() + "ms"); | |
Console.WriteLine(); | |
} | |
static string Inflate(int length) | |
{ | |
StringBuilder sb = new StringBuilder(length); | |
while (sb.Length < length) sb.Append(@"qwerty\"); | |
return sb.ToString(); | |
} | |
static void Main() { | |
Test("Small absolute", @"C:\Windows\Microsoft.NET\Framework\v4.0.30319"); | |
Test("Small relative", @"abcdef\ghijkl\mnopq"); | |
Test("Medium absolute", @"C:\" + Inflate(500)); | |
Test("Medium relative", Inflate(500)); | |
Test("Long absolute", @"C:\" + Inflate(1000)); | |
Test("Long relative", Inflate(1000)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment