Example #1
0
        public static IWriter GetTextFormatter(WriteKind writeKind, string resultFile)
        {
            switch (writeKind)
            {
            case WriteKind.HorizontalBoth:
                return(new RegisterAndResolveCsvHorizontalFileWriter(resultFile));

            case WriteKind.HorizontalRegister:
                return(new RegisterCsvHorizontalFileWriter(resultFile));

            case WriteKind.HorizontalResolve:
                return(new ResolveCsvHorizontalFileWriter(resultFile));

            case WriteKind.VerticalBoth:
                return(new RegisterAndResolveCsvVerticalFileWriter(resultFile));

            case WriteKind.VerticalRegister:
                return(new RegisterCsvVerticalFileWriter(resultFile));

            case WriteKind.VerticalResolve:
                return(new ResolveCsvVerticalFileWriter(resultFile));

            case WriteKind.LatexTableResolve:
                return(new ResolveLatexTableWriter(resultFile));

            case WriteKind.LatexTableRegister:
                return(new RegisterLatexTableWriter(resultFile));

            default:
                throw new ArgumentOutOfRangeException(nameof(writeKind), writeKind, null);
            }
        }
Example #2
0
        private static string ReturnStringResult(KeyValuePair<string, List<FinalTestResult>> result, int index, WriteKind writeKind)
        {
            switch (writeKind)
            {
                case WriteKind.Both:
                    return $"{result.Value[index].MinRegisterTime};{result.Value[index].MaxRegisterTime};{result.Value[index].AvgRegisterTime};" +
                           $"{result.Value[index].MinResolveTime};{result.Value[index].MaxResolveTime};{result.Value[index].AvgResolveTime};";

                case WriteKind.Register:
                    return $"{result.Value[index].MinRegisterTime};{result.Value[index].MaxRegisterTime};{result.Value[index].AvgRegisterTime};";

                case WriteKind.Resolve:
                    return $"{result.Value[index].MinResolveTime};{result.Value[index].MaxResolveTime};{result.Value[index].AvgResolveTime};";
            }

            throw new InvalidOperationException();
        }
Example #3
0
        private static void WriteToFile(Dictionary<string, List<FinalTestResult>> results, WriteKind writeKind)
        {
            var header = new StringBuilder();
            var header2 = new StringBuilder();

            var body1 = new StringBuilder();
            var body2 = new StringBuilder();
            var body3 = new StringBuilder();
            var body4 = new StringBuilder();
            var body5 = new StringBuilder();

            var body6 = new StringBuilder();
            var body7 = new StringBuilder();
            var body8 = new StringBuilder();

            var body9 = new StringBuilder();
            var body10 = new StringBuilder();
            var body11 = new StringBuilder();
            var body12 = new StringBuilder();
            var body13 = new StringBuilder();

            header.Append("Test Case;Registration Kind;Resolve Count;");
            header2.Append(";;;");

            body1.Append("Test A;Singleton;100;");
            body2.Append("Test A;Transient;1;");
            body3.Append("Test A;Transient;10;");
            body4.Append("Test A;Transient;100;");
            body5.Append("Test A;Transient;1000;");

            body6.Append("Test B;Singleton;1;");
            body7.Append("Test B;Transient;1;");
            body8.Append("Test B;Transient;10;");

            body9.Append("Test C;Singleton;100;");
            body10.Append("Test C;Transient;1;");
            body11.Append("Test C;Transient;10;");
            body12.Append("Test C;Transient;100;");
            body13.Append("Test C;Transient;1000;");

            foreach (var result in results)
            {
                switch (writeKind)
                {
                    case WriteKind.Both:
                        header.Append($"{result.Key} Register;{result.Key} Register;{result.Key} Register;" +
                            $"{result.Key} Resolve;{result.Key} Resolve;{result.Key} Resolve;");
                        header2.Append("Min;Max;Avg;Min;Max;Avg;");
                        break;

                    case WriteKind.Register:
                        header.Append($"{result.Key} Register;{result.Key} Register;{result.Key} Register;");
                        header2.Append("Min;Max;Avg;");
                        break;

                    case WriteKind.Resolve:
                        header.Append($"{result.Key} Resolve;{result.Key} Resolve;{result.Key} Resolve;");
                        header2.Append("Min;Max;Avg;");
                        break;
                }

                body1.Append(ReturnStringResult(result, 0, writeKind));
                body2.Append(ReturnStringResult(result, 1, writeKind));
                body3.Append(ReturnStringResult(result, 2, writeKind));
                body4.Append(ReturnStringResult(result, 3, writeKind));
                body5.Append(ReturnStringResult(result, 4, writeKind));
                body6.Append(ReturnStringResult(result, 5, writeKind));
                body7.Append(ReturnStringResult(result, 6, writeKind));
                body8.Append(ReturnStringResult(result, 7, writeKind));
                body9.Append(ReturnStringResult(result, 8, writeKind));
                body10.Append(ReturnStringResult(result, 9, writeKind));
                body11.Append(ReturnStringResult(result, 10, writeKind));
                body12.Append(ReturnStringResult(result, 11, writeKind));
                body13.Append(ReturnStringResult(result, 12, writeKind));
            }

            using (var file = new StreamWriter(_resultFile))
            {
                file.WriteLine(header);
                file.WriteLine(header2);
                file.WriteLine(body1);
                file.WriteLine(body2);
                file.WriteLine(body3);
                file.WriteLine(body4);
                file.WriteLine(body5);
                file.WriteLine(body6);
                file.WriteLine(body7);
                file.WriteLine(body8);
                file.WriteLine(body9);
                file.WriteLine(body10);
                file.WriteLine(body11);
                file.WriteLine(body12);
                file.WriteLine(body13);
            }
        }