private void CachedDaliPerformance(int repeats) { var dt = AllType.GetTableCached(); for (int i = 0; i < repeats; i++) { foreach (DataRow dr in dt.Rows) { AllType inst = new AllType(); inst.Fill(dr); } } }
private void CachedDaliPerformanceParallel(int repeats) { var dt = AllType.GetTableCached(); for (int i = 0; i < repeats; i++) { var instances = dt.Rows.Cast <DataRow>() .AsParallel() .AsOrdered() .Select(dr => { AllType result = new AllType(); result.Fill(dr); return(result); }); instances.ToList(); } }
//[TestMethod] public void CompareUncachedPerformance() { Stopwatch sw = new Stopwatch(); sw.Start(); sw.Stop(); sw.Reset(); AllType.GetTable(); const int reps = 10000; sw.Start(); for (int i = 0; i < reps; i++) { var dt = AllType.GetTable(); foreach (DataRow dr in dt.Rows) { AllType inst = new AllType(); inst.Fill(dr); } } sw.Stop(); Console.WriteLine("DaLi uncached (" + reps + "): " + sw.ElapsedMilliseconds.ToString()); sw.Reset(); sw.Start(); for (int i = 0; i < reps; i++) { var dt = AllType.GetTable(); foreach (DataRow dr in dt.Rows) { PerformanceAllType inst = new PerformanceAllType(); inst.Fill(dr); } } sw.Stop(); Console.WriteLine("Raw implementation uncached (" + reps + "): " + sw.ElapsedMilliseconds.ToString()); }