privatestaticvoidReadCsvFile(Func<string, OutBoundUserCsv> myHandler) { // 透過StreamReader讀取檔案,否則檔案很大的話會拖垮系統 using (var reader = new StreamReader("Input.txt")) { while (!reader.EndOfStream) { var line = reader.ReadLine(); var usr = myHandler.Invoke(line); Console.WriteLine($"UserId:[{usr.UserId}] Name:[{usr.UserName}] "); } } }
privatestatic (long, decimal, int) LoopWorks(Func<long> works, int times) { long total = 0; for (var i = 1; i <= times; i++) { var speed = works.Invoke(); total += speed; }
return (total, Math.Round((decimal) total / times, 2), times); }
privatestaticlongMsSql() { var stopwatch = new Stopwatch(); stopwatch.Start(); var source = new MsSqlAdapter().GetTestData(); stopwatch.Stop(); return stopwatch.ElapsedMilliseconds; }
privatestaticlongMariaDb() { var stopwatch = new Stopwatch(); stopwatch.Start(); var source = new MariaDbAdapter().GetTestData(); stopwatch.Stop(); return stopwatch.ElapsedMilliseconds; }
privatestaticlongOracle() { var stopwatch = new Stopwatch(); stopwatch.Start(); var source = new OracleAdapter().GetTestData(); stopwatch.Stop(); return stopwatch.ElapsedMilliseconds; } }