-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBenchProgram.cs
29 lines (24 loc) · 916 Bytes
/
BenchProgram.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Linq;
using UBench;
namespace Tonttu.Reddit.DailyProgrammer.Challenge3.ScrambledWords.Benchmark {
class BenchProgram {
private const string SortTarget = "öäåzyxwvutsrqponmlkjihgfedcbaÖÄÅZYXWVUTSRQPONMLKJIHGFEDCBA";
static void Main(string[] args) {
Action[] benchmarks = {
() => String.Concat(SortTarget.OrderBy(c => c)),
() => new String(SortTarget.OrderBy(c => c).ToArray()),
() => CopyAndSort(SortTarget)
};
Console.WriteLine(benchmarks.Bench());
Console.WriteLine();
Console.ReadKey();
}
private static string CopyAndSort(string unordered) {
char[] chars = unordered.ToArray();
Array.Sort(chars);
string ordered = new String(chars);
return ordered;
}
}
}