Skip to content

Instantly share code, notes, and snippets.

@jkotas
Created January 4, 2017 15:22
Show Gist options
  • Save jkotas/132e2b8fbe29b69622b322b806635504 to your computer and use it in GitHub Desktop.
Save jkotas/132e2b8fbe29b69622b322b806635504 to your computer and use it in GitHub Desktop.
Path normalization perf test
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