Posts
[Performance][C#]String.Empty V.S ldquo;rdquo;
Console.Clear(); int count = 1000000000; for (int idx = 0; idx < 3; ++idx) { EmptyString1(count); EmptyString2(count); EmptyString3(count); Console.WriteLine(); } } private static void EmptyString1(int count) { String test; Stopwatch sw = Stopwatch.StartNew(); for (int idx = 0; idx < count; ++idx) { test = ""; } sw.Stop(); Console.WriteLine("EmptyString1: " + sw.ElapsedMilliseconds.ToString()); } private static void EmptyString2(int count) { String test; Stopwatch sw = Stopwatch.StartNew(); for (int idx = 0; idx < count; ++idx) { test = string.
read morePosts
[Performance][C#]同時判斷多個字串是否為數值型態
sw.Reset(); sw.Start(); for (int idx = 0; idx < testCount; ++idx) { IsNumeric2_1(values); } sw.Stop(); Console.WriteLine("Method2-1: " + sw.ElapsedMilliseconds + " ms"); sw.Reset(); sw.Start(); for (int idx = 0; idx < testCount; ++idx) { IsNumeric2_2(values); } sw.Stop(); Console.WriteLine("Method2-2: " + sw.ElapsedMilliseconds + " ms"); sw.Reset(); sw.Start(); for (int idx = 0; idx < testCount; ++idx) { IsNumeric3(values); } sw.Stop(); Console.WriteLine("Method3: " + sw.ElapsedMilliseconds + " ms"); sw.Reset(); sw.Start(); for (int idx = 0; idx < testCount; ++idx) { IsNumeric4(values); } sw.
read more