public static void autoSingleResultTest(IEnumerable<Product> products) { TestingEnvironment.BenchmarkQuery(() => from Product p in products.AsOptimizable() where (from Product p2 in products select p2.unitPrice).Max() == p.unitPrice select p.productName, ref products, "AsOptimizable Max Query Expession", "from Product p in products.AsOptimizable()\n where (from Product p2 in products select p2.unitPrice).Max() == p.unitPrice\nselect p.productName" ); TestingEnvironment.BenchmarkQuery(() => products.Select(p2 => p2.unitPrice).GroupBy(key => 0).Select(pg => pg.Max()).SelectMany(uMax => products.Where(p => uMax == p.unitPrice).Select(p => p.productName)), ref products, "Optimized Max With GroupBy operator", "products.Select(p2 => p2.unitPrice).GroupBy(key => 0).Select(pg => pg.Max()).SelectMany(uMax => products.Where(p => uMax == p.unitPrice).Select(p => p.productName))" ); }
public static void autoInnerQueryTest(IEnumerable<Product> products) { /* Func<IEnumerable<string>> func = Expression.Lambda<Func<IEnumerable<string>>>(OptimizerExtensions.AsGroup(() => products.Where(p2 => p2.productName == "Ikura").Select(p2 => p2.unitPrice).ToList()).AsQueryable().SelectMany(uThunk => products.Where(p => uThunk.Value.Contains(p.unitPrice)).Select(p => p.productName)).Expression).Compile(); TestingEnvironment.BenchmarkQuery(func, ref products, "Optimized Ikura With AsGroupSuspendedSelectMany operator using Func (ARTIFICIALY COMPILED)", "OptimizerExtensions.AsGroup(() => products.Where(p2 => p2.productName == \"Ikura\").Select(p2 => p2.unitPrice).ToList()).SelectMany(uThunk => products.Where(p => uThunk.Value.Contains(p.unitPrice)).Select(p => p.productName))" );*/ TestingEnvironment.BenchmarkQuery(() => from Product p in products.AsOptimizable() where (from Product p2 in products where p2.productName == "Ikura" select p2.unitPrice).Contains(p.unitPrice) select p.productName, ref products, "AsOptimizable Ikura Query Expession", "from Product p in products.AsOptimizable()\n where (from Product p2 in products where p2.productName == \"Ikura\" select p2.unitPrice).Contains(p.unitPrice)\nselect p.productName" ); }