public void TableValuedPerformanceTest() { var songs = Database.MListQuery((AlbumEntity a) => a.Songs).Select(a => a.Element); var t1 = PerfCounter.Ticks; var fast = (from s1 in songs from s2 in songs from s3 in songs from s4 in songs select MinimumExtensions.MinimumTableValued( MinimumExtensions.MinimumTableValued(s1.Seconds, s2.Seconds).Select(a => a.MinValue).First(), MinimumExtensions.MinimumTableValued(s3.Seconds, s4.Seconds).Select(a => a.MinValue).First() ).Select(a => a.MinValue).First()).ToList(); var t2 = PerfCounter.Ticks; var fast2 = (from s1 in songs from s2 in songs from s3 in songs from s4 in songs let x = MinimumExtensions.MinimumTableValued(s1.Seconds, s2.Seconds).Select(a => a.MinValue).First() let y = MinimumExtensions.MinimumTableValued(s3.Seconds, s4.Seconds).Select(a => a.MinValue).First() select MinimumExtensions.MinimumTableValued(x, y).Select(a => a.MinValue).First()).ToList(); var t3 = PerfCounter.Ticks; var slow = (from s1 in songs from s2 in songs from s3 in songs from s4 in songs let x = MinimumExtensions.MinimumScalar(s1.Seconds, s2.Seconds) let y = MinimumExtensions.MinimumScalar(s3.Seconds, s4.Seconds) select MinimumExtensions.MinimumScalar(x, y)).ToList(); var t4 = PerfCounter.Ticks; if (!Schema.Current.Settings.IsPostgres) { Debug.WriteLine("MinimumTableValued: {0} ms", PerfCounter.ToMilliseconds(t1, t2)); Debug.WriteLine("MinimumTableValued let: {0} ms", PerfCounter.ToMilliseconds(t2, t3)); Debug.WriteLine("MinimumScalar: {0} ms", PerfCounter.ToMilliseconds(t3, t4)); } }
public void TableValuedPerformanceTest() { var songs = Database.MListQuery((AlbumEntity a) => a.Songs).Select(a => a.Element); var t1 = PerfCounter.Ticks; var fast = (from s1 in songs from s2 in songs from s3 in songs from s4 in songs select MinimumExtensions.MinimumTableValued( MinimumExtensions.MinimumTableValued(s1.Seconds, s2.Seconds).Select(a => a.MinValue).First(), MinimumExtensions.MinimumTableValued(s3.Seconds, s4.Seconds).Select(a => a.MinValue).First() ).Select(a => a.MinValue).First()).ToList(); var t2 = PerfCounter.Ticks; var fast2 = (from s1 in songs from s2 in songs from s3 in songs from s4 in songs let x = MinimumExtensions.MinimumTableValued(s1.Seconds, s2.Seconds).Select(a => a.MinValue).First() let y = MinimumExtensions.MinimumTableValued(s3.Seconds, s4.Seconds).Select(a => a.MinValue).First() select MinimumExtensions.MinimumTableValued(x, y).Select(a => a.MinValue).First()).ToList(); var t3 = PerfCounter.Ticks; var slow = (from s1 in songs from s2 in songs from s3 in songs from s4 in songs let x = MinimumExtensions.MinimumScalar(s1.Seconds, s2.Seconds) let y = MinimumExtensions.MinimumScalar(s3.Seconds, s4.Seconds) select MinimumExtensions.MinimumScalar(x, y)).ToList(); var t4 = PerfCounter.Ticks; Assert.IsTrue(PerfCounter.ToMilliseconds(t1, t2) < PerfCounter.ToMilliseconds(t3, t4)); Assert.IsTrue(PerfCounter.ToMilliseconds(t2, t3) < PerfCounter.ToMilliseconds(t3, t4)); }