private static void ReportMemoryUsageIndividualResult(BenchResult result) { Console.WriteLine("[{0:HH:mm:ss}] # of elements fetched individually: {1}.\tTotal time: {2:N2}ms.\tAllocated bytes per element: {3}.", DateTime.Now, KeysForIndividualFetches.Count, result.FetchTimeInMilliseconds, result.NumberOfBytesAllocated); }
private static void ReportMemoryUsageEagerLoadResult(BenchResult result) { Console.WriteLine("[{0:HH:mm:ss}] # of elements fetched: {1} ({2}).\tFetch took: {3:N2}ms. Allocated bytes: {3}.", DateTime.Now, result.TotalNumberOfRowsFetched, string.Join(" + ", result.NumberOfRowsFetchedPerType.Select(kvp => kvp.Value).ToArray()), result.NumberOfBytesAllocated); }
private static void ReportEagerLoadResult(BenchResult result) { Console.WriteLine("[{0:HH:mm:ss}] # of elements fetched: {1} ({2}).\tFetch took: {3:N2}ms.", DateTime.Now, result.TotalNumberOfRowsFetched, string.Join(" + ", result.NumberOfRowsFetchedPerType.Select(kvp => kvp.Value).ToArray()), result.FetchTimeInMilliseconds); }
private static void ReportMemoryUsageSetResult(BenchResult result) { Console.WriteLine("[{0:HH:mm:ss}] # of elements fetched: {1}.\tFetch took: {2:N2}ms.\tAllocated bytes: {3}.", DateTime.Now, result.TotalNumberOfRowsFetched, result.FetchTimeInMilliseconds, result.NumberOfBytesAllocated); }
private static void ReportSetResult(BenchResult result) { Console.WriteLine("[{0:HH:mm:ss}] # of elements fetched: {1}.\tFetch took: {2:N2}ms.\tEnumerating result took: {3:N2}ms.", DateTime.Now, result.TotalNumberOfRowsFetched, result.FetchTimeInMilliseconds, result.EnumerationTimeInMilliseconds); }
private static void ReportIndividualResult(BenchResult result) { Console.WriteLine("[{0:HH:mm:ss}] # of elements fetched individually: {1}.\tTotal time: {2:N2}ms.\tTime per element: {3:N2}ms", DateTime.Now, KeysForIndividualFetches.Count, result.FetchTimeInMilliseconds, result.FetchTimeInMilliseconds / KeysForIndividualFetches.Count); }
private static void ReportSetResult(IBencher bencher, BenchResult result) { WriteLine("Number of elements fetched: {0}.\tFetch took: {1}ms.\tEnumerating result took: {2}ms", result.NumberOfRowsFetched, result.FetchTimeInMilliseconds, result.EnumerationTimeInMilliseconds); }
private static void ReportIndividualResult(IBencher bencher, BenchResult result) { Console.WriteLine("[{0}] Number of elements fetched individually: {1}.\tTotal time: {2:N2}ms.\tTime per element: {3:N2}ms", DateTime.Now.ToString("HH:mm:ss"), KeysForIndividualFetches.Count, result.FetchTimeInMilliseconds, result.FetchTimeInMilliseconds / KeysForIndividualFetches.Count); }
private static void ReportInsertSetResult(BenchResult result) { Console.WriteLine("[{0:HH:mm:ss}] # of elements inserted as set: {1} (batch size: {2}).\tSet insert took: {3:N2}ms.", DateTime.Now, result.TotalNumberOfRowsAffected, result.InsertBatchSize, result.ActionTimeInMilliseconds); }
private static void ReportMemoryUsageInsertSetResult(BenchResult result) { Console.WriteLine("[{0:HH:mm:ss}] # of elements inserted as set: {1}.\tSet insert took: {2:N2}ms.\tAllocated bytes: {3}.", DateTime.Now, result.TotalNumberOfRowsAffected, result.ActionTimeInMilliseconds, result.NumberOfBytesAllocated); }
private static void RunBencher(IBencher bencher) { bencher.ResetResults(); Console.WriteLine("First one warm-up run of each bench type to initialize constructs. Results will not be collected."); BenchResult result = null; if (PerformSetBenchmarks && bencher.SupportsSetFetch) { result = bencher.PerformSetBenchmark(discardResults: true); BenchController.ReportSetResult(result); } if (bencher.SupportsEagerLoading) { result = bencher.PerformEagerLoadBenchmark(discardResults: true); BenchController.ReportEagerLoadResult(result); if (PerformAsyncBenchmarks && bencher.SupportsAsync) { result = bencher.PerformAsyncEagerLoadBenchmark(discardResults: true); BenchController.ReportEagerLoadResult(result); } } if (PerformIndividualBenchMarks && bencher.SupportsIndividualFetch) { result = bencher.PerformIndividualBenchMark(KeysForIndividualFetches, discardResults: true); BenchController.ReportIndividualResult(result); } if (PerformSetInsertBenchmarks && bencher.SupportsInserts) { result = bencher.PerformInsertSetBenchmark(InsertSetSize, InsertBatchSizeDefault, discardResults: true); BenchController.ReportInsertSetResult(result); } Console.WriteLine("Doing a GC collect..."); BenchController.ForceGCCollect(); Console.WriteLine("Done."); Console.WriteLine("\nStarting bench runs..."); if (PerformSetBenchmarks && bencher.SupportsSetFetch) { // set benches Console.WriteLine("Set fetches"); Console.WriteLine("-------------------------"); for (int i = 0; i < LoopAmount; i++) { result = bencher.PerformSetBenchmark(); BenchController.ReportSetResult(result); // avoid having the GC collect in the middle of a run. BenchController.ForceGCCollect(); } } if (PerformIndividualBenchMarks && bencher.SupportsIndividualFetch) { // individual benches Console.WriteLine("\nSingle element fetches"); Console.WriteLine("-------------------------"); for (int i = 0; i < LoopAmount; i++) { result = bencher.PerformIndividualBenchMark(KeysForIndividualFetches); BenchController.ReportIndividualResult(result); // avoid having the GC collect in the middle of a run. BenchController.ForceGCCollect(); if (ApplyAntiFloodForVMUsage) { // sleep is to avoid hammering the network layer on the target server. If the target server is a VM, it might stall once or twice // during benching, which is not what we want at it can skew the results a lot. In a very short time, a lot of queries are executed // on the target server (LoopAmount * IndividualKeysAmount), which will hurt performance on VMs with very fast frameworks in some // cases in some runs (so more than 2 runs are slow). #pragma warning disable CS0162 Thread.Sleep(400); #pragma warning restore CS0162 } } } if (PerformEagerLoadBenchmarks && bencher.SupportsEagerLoading) { // eager load benches Console.WriteLine("\nEager Load fetches"); Console.WriteLine("-------------------------"); for (int i = 0; i < LoopAmount; i++) { result = bencher.PerformEagerLoadBenchmark(); BenchController.ReportEagerLoadResult(result); // avoid having the GC collect in the middle of a run. BenchController.ForceGCCollect(); } } if (PerformAsyncBenchmarks && bencher.SupportsEagerLoading && bencher.SupportsAsync) { // eager load benches Console.WriteLine("\nAsync eager Load fetches"); Console.WriteLine("-------------------------"); for (int i = 0; i < LoopAmount; i++) { result = bencher.PerformAsyncEagerLoadBenchmark(discardResults: false); BenchController.ReportEagerLoadResult(result); // avoid having the GC collect in the middle of a run. BenchController.ForceGCCollect(); } } if (PerformSetInsertBenchmarks && bencher.SupportsInserts) { // set insert benches Console.WriteLine("\nSet Inserts"); Console.WriteLine("-------------------------"); for (int i = 0; i < LoopAmount; i++) { result = bencher.PerformInsertSetBenchmark(InsertSetSize, InsertBatchSizeDefault); BenchController.ReportInsertSetResult(result); // avoid having the GC collect in the middle of a run. BenchController.ForceGCCollect(); } } }
private static void ReportEagerLoadResult(IBencher bencher, BenchResult result) { Console.WriteLine("[{0}] Number of elements fetched: {1} ({2}).\tFetch took: {3:N2}ms.", DateTime.Now.ToString("HH:mm:ss"), result.TotalNumberOfRowsFetched, string.Join(" + ", result.NumberOfRowsFetchedPerType.Select(kvp=>kvp.Value).ToArray()), result.FetchTimeInMilliseconds); }
private static void ReportSetResult(IBencher bencher, BenchResult result) { Console.WriteLine("Number of elements fetched: {0}.\tFetch took: {1}ms.\tEnumerating result took: {2}ms", result.NumberOfRowsFetched, result.FetchTimeInMilliseconds, result.EnumerationTimeInMilliseconds); }
private static void ReportIndividualResult(IBencher bencher, BenchResult result) { WriteLine("Number of elements fetched individually: {0}.\tTotal time: {1}ms.\tTime per element: {2}ms", KeysForIndividualFetches.Count, result.FetchTimeInMilliseconds, (double)result.FetchTimeInMilliseconds / (double)KeysForIndividualFetches.Count); }
private static void ReportIndividualResult(IBencher bencher, BenchResult result) { Console.WriteLine("Number of elements fetched individually: {0}.\tTotal time: {1}ms.\tTime per element: {2}ms", KeysForIndividualFetches.Count, result.FetchTimeInMilliseconds, (double)result.FetchTimeInMilliseconds / (double)KeysForIndividualFetches.Count); }
private static void ReportSetResult(BenchResult result) { Console.WriteLine("[{0}] Number of elements fetched: {1}.\tFetch took: {2:N2}ms.\tEnumerating result took: {3:N2}ms", DateTime.Now.ToString("HH:mm:ss"), result.TotalNumberOfRowsFetched, result.FetchTimeInMilliseconds, result.EnumerationTimeInMilliseconds); }