示例#1
0
        private static string FormatBenchmarkResults(IOperationResultBase benchmarkResult, int nestingLevel)
        {
            string formattedResults = nestingLevel == 0 ? "" : new string('-', nestingLevel * 3) + '→' + ' ';
            string label = benchmarkResult is IOperationGroupResult ? benchmarkResult.Name + " (Group Total)" : benchmarkResult.Name;

            formattedResults += string.Format("{0}: {1}", label.PadRight(22), benchmarkResult.Durations.Min.TotalMilliseconds.ToString("0.000 ms.").PadLeft(12));

            if (benchmarkResult is IOperationWithFuncResult)
                formattedResults += string.Format("{0}Return Value: {1}", new string(' ', 3), ((IOperationWithFuncResult)benchmarkResult).FuncReturnValue);

            if (benchmarkResult is IOperationGroupResult)
            {
                IOperationGroupResult benchmarkResultTyped = (IOperationGroupResult)benchmarkResult;

                foreach (IOperationResultBase childOperationResult in benchmarkResultTyped.ChildOperationResults)
                    formattedResults += Environment.NewLine + FormatBenchmarkResults(childOperationResult, nestingLevel + 1);
            }

            return formattedResults;
        }
示例#2
0
        private static string FormatBenchmarkResults(IOperationResultBase benchmarkResult, int nestingLevel)
        {
            string formattedResults = nestingLevel == 0 ? "" : new string('-', nestingLevel * 3) + '→' + ' ';
            string label            = benchmarkResult is IOperationGroupResult ? benchmarkResult.Name + " (Group Total)" : benchmarkResult.Name;

            formattedResults += string.Format("{0}: {1}", label.PadRight(22), benchmarkResult.Durations.Min.TotalMilliseconds.ToString("0.000 ms.").PadLeft(12));

            if (benchmarkResult is IOperationWithFuncResult)
            {
                formattedResults += string.Format("{0}Return Value: {1}", new string(' ', 3), ((IOperationWithFuncResult)benchmarkResult).FuncReturnValue);
            }

            if (benchmarkResult is IOperationGroupResult)
            {
                IOperationGroupResult benchmarkResultTyped = (IOperationGroupResult)benchmarkResult;

                foreach (IOperationResultBase childOperationResult in benchmarkResultTyped.ChildOperationResults)
                {
                    formattedResults += Environment.NewLine + FormatBenchmarkResults(childOperationResult, nestingLevel + 1);
                }
            }

            return(formattedResults);
        }