public static ExecutionOutcomeWithId FromDynamicJsonObject(dynamic jsonObject)
        {
            var result = new ExecutionOutcomeWithId()
            {
                Id      = jsonObject.id,
                Outcome = ExecutionOutcome.FromDynamicJsonObject(jsonObject.outcome)
            };

            return(result);
        }
Example #2
0
        private void WriteBuildStatistics()
        {
            // The Count'th element corresponds to totals over all compiler runners used in the run
            int[,] compilationOutcomes = new int[(int)CompilationOutcome.Count, (int)CompilerIndex.Count + 1];
            int[,] executionOutcomes   = new int[(int)ExecutionOutcome.Count, (int)CompilerIndex.Count + 1];
            int totalCompilations = 0;
            int totalExecutions   = 0;

            foreach (BuildFolder folder in _buildFolders)
            {
                bool[] compilationFailedPerRunner = new bool[(int)CompilerIndex.Count];
                foreach (ProcessInfo[] compilation in folder.Compilations)
                {
                    totalCompilations++;
                    bool anyCompilationFailed = false;
                    foreach (CompilerRunner runner in _compilerRunners)
                    {
                        bool compilationFailed = compilation[(int)runner.Index] != null && !compilation[(int)runner.Index].Succeeded;
                        if (compilationFailed)
                        {
                            compilationOutcomes[(int)CompilationOutcome.FAIL, (int)runner.Index]++;
                            anyCompilationFailed = true;
                            compilationFailedPerRunner[(int)runner.Index] = true;
                        }
                        else
                        {
                            compilationOutcomes[(int)CompilationOutcome.PASS, (int)runner.Index]++;
                        }
                    }
                    if (anyCompilationFailed)
                    {
                        compilationOutcomes[(int)CompilationOutcome.FAIL, (int)CompilerIndex.Count]++;
                    }
                    else
                    {
                        compilationOutcomes[(int)CompilationOutcome.PASS, (int)CompilerIndex.Count]++;
                    }
                }

                foreach (ProcessInfo[] execution in folder.Executions)
                {
                    totalExecutions++;
                    bool anyCompilationFailed        = false;
                    int  executionFailureOutcomeMask = 0;
                    foreach (CompilerRunner runner in _compilerRunners)
                    {
                        ProcessInfo execProcess       = execution[(int)runner.Index];
                        bool        compilationFailed = compilationFailedPerRunner[(int)runner.Index];
                        anyCompilationFailed |= compilationFailed;
                        bool executionFailed = !compilationFailed && (execProcess != null && !execProcess.Succeeded);
                        if (executionFailed)
                        {
                            ExecutionOutcome outcome = (execProcess.TimedOut ? ExecutionOutcome.TIMED_OUT :
                                                        execProcess.ExitCode < -1000 * 1000 ? ExecutionOutcome.CRASHED :
                                                        ExecutionOutcome.EXIT_CODE);
                            executionOutcomes[(int)outcome, (int)runner.Index]++;
                            executionFailureOutcomeMask |= 1 << (int)outcome;
                        }
                        if (!compilationFailed && !executionFailed)
                        {
                            executionOutcomes[(int)ExecutionOutcome.PASS, (int)runner.Index]++;
                        }
                    }
                    if (executionFailureOutcomeMask != 0)
                    {
                        for (int outcomeIndex = 0; outcomeIndex < (int)ExecutionOutcome.Count; outcomeIndex++)
                        {
                            if ((executionFailureOutcomeMask & (1 << outcomeIndex)) != 0)
                            {
                                executionOutcomes[outcomeIndex, (int)CompilerIndex.Count]++;
                            }
                        }
                    }
                    else
                    {
                        executionOutcomes[(int)ExecutionOutcome.PASS, (int)CompilerIndex.Count]++;
                    }
                }
            }

            _logWriter.WriteLine();
            _logWriter.WriteLine($"Total folders:    {_buildFolders.Count()}");
            _logWriter.WriteLine($"# compilations:   {totalCompilations}");
            _logWriter.WriteLine($"# executions:     {totalExecutions}");
            _logWriter.WriteLine($"Total build time: {_buildMilliseconds} msecs");
            _logWriter.WriteLine($"Compilation time: {_compilationMilliseconds} msecs");
            _logWriter.WriteLine($"Execution time:   {_executionMilliseconds} msecs");

            _logWriter.WriteLine();
            _logWriter.Write($"{totalCompilations,7} ILC |");
            foreach (CompilerRunner runner in _compilerRunners)
            {
                _logWriter.Write($"{runner.CompilerName,8} |");
            }
            _logWriter.WriteLine(" Overall");
            int    lineSize  = 10 * _compilerRunners.Count() + 13 + 8;
            string separator = new string('-', lineSize);

            _logWriter.WriteLine(separator);
            for (int outcomeIndex = 0; outcomeIndex < (int)CompilationOutcome.Count; outcomeIndex++)
            {
                _logWriter.Write($"{((CompilationOutcome)outcomeIndex).ToString(),11} |");
                foreach (CompilerRunner runner in _compilerRunners)
                {
                    _logWriter.Write($"{compilationOutcomes[outcomeIndex, (int)runner.Index],8} |");
                }
                _logWriter.WriteLine($"{compilationOutcomes[outcomeIndex, (int)CompilerIndex.Count],8}");
            }

            if (!_options.NoExe)
            {
                _logWriter.WriteLine();
                _logWriter.Write($"{totalExecutions,7} EXE |");
                foreach (CompilerRunner runner in _compilerRunners)
                {
                    _logWriter.Write($"{runner.CompilerName,8} |");
                }
                _logWriter.WriteLine(" Overall");
                _logWriter.WriteLine(separator);
                for (int outcomeIndex = 0; outcomeIndex < (int)ExecutionOutcome.Count; outcomeIndex++)
                {
                    _logWriter.Write($"{((ExecutionOutcome)outcomeIndex).ToString(),11} |");
                    foreach (CompilerRunner runner in _compilerRunners)
                    {
                        _logWriter.Write($"{executionOutcomes[outcomeIndex, (int)runner.Index],8} |");
                    }
                    _logWriter.WriteLine($"{executionOutcomes[outcomeIndex, (int)CompilerIndex.Count],8}");
                }
            }

            WriteJittedMethodSummary();

            WriteTopRankingProcesses("compilations by duration", EnumerateCompilations());
            WriteTopRankingProcesses("executions by duration", EnumerateExecutions());
        }
        private void WriteBuildStatistics(StreamWriter logWriter)
        {
            // The Count'th element corresponds to totals over all compiler runners used in the run
            int[,] compilationOutcomes = new int[(int)CompilationOutcome.Count, (int)CompilerIndex.Count + 1];
            int[,] executionOutcomes   = new int[(int)ExecutionOutcome.Count, (int)CompilerIndex.Count + 1];
            int totalCompilations = 0;
            int totalExecutions   = 0;

            foreach (BuildFolder folder in FoldersToBuild)
            {
                bool[] compilationFailedPerRunner = new bool[(int)CompilerIndex.Count];
                foreach (ProcessInfo[] compilation in folder.Compilations)
                {
                    totalCompilations++;
                    bool anyCompilationFailed = false;
                    foreach (CompilerRunner runner in _compilerRunners)
                    {
                        bool compilationFailed = compilation[(int)runner.Index] != null && !compilation[(int)runner.Index].Succeeded;
                        if (compilationFailed)
                        {
                            compilationOutcomes[(int)CompilationOutcome.FAIL, (int)runner.Index]++;
                            anyCompilationFailed = true;
                            compilationFailedPerRunner[(int)runner.Index] = true;
                        }
                        else
                        {
                            compilationOutcomes[(int)CompilationOutcome.PASS, (int)runner.Index]++;
                        }
                    }
                    if (anyCompilationFailed)
                    {
                        compilationOutcomes[(int)CompilationOutcome.FAIL, (int)CompilerIndex.Count]++;
                    }
                    else
                    {
                        compilationOutcomes[(int)CompilationOutcome.PASS, (int)CompilerIndex.Count]++;
                    }
                }

                foreach (ProcessInfo[] execution in folder.Executions)
                {
                    totalExecutions++;
                    bool anyCompilationFailed        = false;
                    int  executionFailureOutcomeMask = 0;
                    foreach (CompilerRunner runner in _compilerRunners)
                    {
                        ProcessInfo execProcess       = execution[(int)runner.Index];
                        bool        compilationFailed = compilationFailedPerRunner[(int)runner.Index];
                        anyCompilationFailed |= compilationFailed;
                        bool executionFailed = !compilationFailed && (execProcess != null && !execProcess.Succeeded);
                        if (executionFailed)
                        {
                            ExecutionOutcome outcome = (execProcess.TimedOut ? ExecutionOutcome.TIMED_OUT :
                                                        execProcess.ExitCode < -1000 * 1000 ? ExecutionOutcome.CRASHED :
                                                        ExecutionOutcome.EXIT_CODE);
                            executionOutcomes[(int)outcome, (int)runner.Index]++;
                            executionFailureOutcomeMask |= 1 << (int)outcome;
                        }
                        if (!compilationFailed && !executionFailed)
                        {
                            executionOutcomes[(int)ExecutionOutcome.PASS, (int)runner.Index]++;
                        }
                    }
                    if (executionFailureOutcomeMask != 0)
                    {
                        for (int outcomeIndex = 0; outcomeIndex < (int)ExecutionOutcome.Count; outcomeIndex++)
                        {
                            if ((executionFailureOutcomeMask & (1 << outcomeIndex)) != 0)
                            {
                                executionOutcomes[outcomeIndex, (int)CompilerIndex.Count]++;
                            }
                        }
                    }
                    else
                    {
                        executionOutcomes[(int)ExecutionOutcome.PASS, (int)CompilerIndex.Count]++;
                    }
                }
            }

            logWriter.WriteLine();
            logWriter.WriteLine($"Configuration:    {(_options.Release ? "Release" : "Debug")}");
            logWriter.WriteLine($"Framework:        {(_options.Framework ? "build native" : _options.UseFramework ? "prebuilt native" : "MSIL")}");
            logWriter.WriteLine($"Version bubble:   {(_options.LargeBubble ? "input + all reference assemblies" : "single assembly")}");
            logWriter.WriteLine($"Input folder:     {_options.InputDirectory?.FullName}");
            logWriter.WriteLine($"CORE_ROOT:        {_options.CoreRootDirectory?.FullName}");
            logWriter.WriteLine($"CPAOT:            {_options.CpaotDirectory?.FullName}");
            logWriter.WriteLine($"Total folders:    {_buildFolders.Count()}");
            logWriter.WriteLine($"Blocked w/issues: {_buildFolders.Count(folder => folder.IsBlockedWithIssue)}");
            int foldersToBuild = FoldersToBuild.Count();

            logWriter.WriteLine($"Folders to build: {foldersToBuild}");
            logWriter.WriteLine($"# compilations:   {totalCompilations}");
            logWriter.WriteLine($"# executions:     {totalExecutions}");
            logWriter.WriteLine($"Total build time: {_buildMilliseconds} msecs");
            logWriter.WriteLine($"Framework time:   {_frameworkCompilationMilliseconds} msecs");
            logWriter.WriteLine($"Compilation time: {_compilationMilliseconds} msecs");
            logWriter.WriteLine($"Execution time:   {_executionMilliseconds} msecs");

            if (foldersToBuild != 0)
            {
                logWriter.WriteLine();
                logWriter.Write($"{totalCompilations,7} ILC |");
                foreach (CompilerRunner runner in _compilerRunners)
                {
                    logWriter.Write($"{runner.CompilerName,8} |");
                }
                logWriter.WriteLine(" Overall");
                int    lineSize  = 10 * _compilerRunners.Count() + 13 + 8;
                string separator = new string('-', lineSize);
                logWriter.WriteLine(separator);
                for (int outcomeIndex = 0; outcomeIndex < (int)CompilationOutcome.Count; outcomeIndex++)
                {
                    logWriter.Write($"{((CompilationOutcome)outcomeIndex).ToString(),11} |");
                    foreach (CompilerRunner runner in _compilerRunners)
                    {
                        logWriter.Write($"{compilationOutcomes[outcomeIndex, (int)runner.Index],8} |");
                    }
                    logWriter.WriteLine($"{compilationOutcomes[outcomeIndex, (int)CompilerIndex.Count],8}");
                }

                if (!_options.NoExe)
                {
                    logWriter.WriteLine();
                    logWriter.Write($"{totalExecutions,7} EXE |");
                    foreach (CompilerRunner runner in _compilerRunners)
                    {
                        logWriter.Write($"{runner.CompilerName,8} |");
                    }
                    logWriter.WriteLine(" Overall");
                    logWriter.WriteLine(separator);
                    for (int outcomeIndex = 0; outcomeIndex < (int)ExecutionOutcome.Count; outcomeIndex++)
                    {
                        logWriter.Write($"{((ExecutionOutcome)outcomeIndex).ToString(),11} |");
                        foreach (CompilerRunner runner in _compilerRunners)
                        {
                            logWriter.Write($"{executionOutcomes[outcomeIndex, (int)runner.Index],8} |");
                        }
                        logWriter.WriteLine($"{executionOutcomes[outcomeIndex, (int)CompilerIndex.Count],8}");
                    }
                }

                WritePerFolderStatistics(logWriter);

                WriteExecutableSizeStatistics(logWriter);

                WriteJittedMethodSummary(logWriter);

                WriteTopRankingProcesses(logWriter, "compilations by duration", EnumerateCompilations());
                WriteTopRankingProcesses(logWriter, "executions by duration", EnumerateExecutions());
            }

            if (_options.Framework)
            {
                logWriter.WriteLine();
                logWriter.WriteLine("Framework compilation failures:");
                FrameworkCompilationFailureBuckets.WriteToStream(logWriter, detailed: false);
            }

            if (foldersToBuild != 0)
            {
                logWriter.WriteLine();
                logWriter.WriteLine("Compilation failures:");
                CompilationFailureBuckets.WriteToStream(logWriter, detailed: false);

                if (!_options.NoExe)
                {
                    logWriter.WriteLine();
                    logWriter.WriteLine("Execution failures:");
                    ExecutionFailureBuckets.WriteToStream(logWriter, detailed: false);
                }
            }

            WriteFoldersBlockedWithIssues(logWriter);
        }
Example #4
0
        public void ShouldHaveCorrectFinalResult()
        {
            var excStatus = new ExecutionStatus()
            {
                SuccessReceiptId = "11112"
            };
            var excOutcome = new ExecutionOutcome()
            {
                Status     = excStatus,
                Logs       = new string[0],
                ReceiptIds = new string[] { "11112" },
                GasBurnt   = 1
            };
            var transaction = new ExecutionOutcomeWithId()
            {
                Id      = "11111",
                Outcome = excOutcome
            };
            var firstExcStatus = new ExecutionStatus()
            {
                SuccessValue = "e30="
            };
            var firstExcOutcome = new ExecutionOutcome()
            {
                Status     = firstExcStatus,
                Logs       = new string[0],
                ReceiptIds = new string[] { "11112" },
                GasBurnt   = 9001
            };
            var secondExcStatus = new ExecutionStatus()
            {
                SuccessValue = ""
            };
            var secondExcOutcome = new ExecutionOutcome()
            {
                Status     = secondExcStatus,
                Logs       = new string[0],
                ReceiptIds = new string[0],
                GasBurnt   = 0
            };
            var receipts = new ExecutionOutcomeWithId[] {
                new ExecutionOutcomeWithId {
                    Id = "11112", Outcome = firstExcOutcome
                },
                new ExecutionOutcomeWithId {
                    Id = "11113", Outcome = secondExcOutcome
                }
            };
            var result = new FinalExecutionOutcome()
            {
                Status = new FinalExecutionStatus()
                {
                    SuccessValue = "e30="
                },
                Transaction = transaction,
                Receipts    = receipts
            };
            dynamic lastResult = Provider.GetTransactionLastResult(result);

            Assert.IsFalse(lastResult is null);
        }