Пример #1
0
        /// <summary>
        /// Compiles the method referenced by this method compiler.
        /// </summary>
        public void Compile()
        {
            BeginCompile();

            foreach (IMethodCompilerStage stage in Pipeline)
            {
                {
                    stage.Initialize(this);
                    stage.Execute();

                    InstructionLogger.Run(this, stage);

                    if (stop)
                    {
                        break;
                    }
                }
            }

            InitializeType();

            var log = new TraceLog(TraceType.Counters, this.Method, string.Empty, Trace.TraceFilter.Active);

            log.Log(MethodData.Counters.Export());
            Trace.TraceListener.OnNewTraceLog(log);

            EndCompile();
        }
Пример #2
0
        /// <summary>
        /// Compiles the method referenced by this method compiler.
        /// </summary>
        public void Compile()
        {
            int position = 0;

            foreach (var stage in Pipeline)
            {
                stage.Setup(this, ++position);
                stage.Execute();

                InstructionLogger.Run(this, stage);

                if (IsStopped)
                {
                    break;
                }
            }

            InitializeType();

            var log = new TraceLog(TraceType.Counters, Method, string.Empty, Trace.TraceFilter.Active);

            log.Log(MethodData.Counters.Export());
            Trace.TraceListener.OnNewTraceLog(log);
        }
Пример #3
0
        private void ExecutePipeline()
        {
            if (!IsExecutePipeline)
            {
                return;
            }

            var executionTimes = new long[Pipeline.Count];

            var startTick = Stopwatch.ElapsedTicks;

            for (int i = 0; i < Pipeline.Count; i++)
            {
                var stage = Pipeline[i];

                stage.Setup(this, i);
                stage.Execute();

                executionTimes[i] = Stopwatch.ElapsedTicks;

                InstructionLogger.Run(this, stage);

                if (IsStopped || IsMethodInlined)
                {
                    break;
                }
            }

            if (Compiler.CompilerOptions.EnableStatistics)
            {
                var lastTick = Stopwatch.ElapsedTicks;

                MethodData.ElapsedTicks = lastTick;

                MethodData.Counters.NewCountSkipLock("ExecutionTime.StageStart.Ticks", (int)startTick);
                MethodData.Counters.NewCountSkipLock("ExecutionTime.Total.Ticks", (int)lastTick);

                var executionTimeLog = new TraceLog(TraceType.MethodDebug, Method, "Execution Time/Ticks", MethodData.Version);

                long previousTick = startTick;
                var  totalTick    = lastTick - startTick;

                for (int i = 0; i < Pipeline.Count; i++)
                {
                    var pipelineTick = executionTimes[i];
                    var ticks        = pipelineTick == 0 ? 0 : pipelineTick - previousTick;
                    var percentage   = totalTick == 0 ? 0 : (ticks * 100) / (double)(totalTick);
                    previousTick = pipelineTick;

                    int per = (int)percentage / 5;

                    var entry = $"[{i:00}] {Pipeline[i].Name.PadRight(45)} : {percentage:00.00} % [{string.Empty.PadRight(per, '#').PadRight(20, ' ')}] ({ticks})";

                    executionTimeLog.Log(entry);

                    MethodData.Counters.NewCountSkipLock($"ExecutionTime.{i:00}.{Pipeline[i].Name}.Ticks", (int)ticks);
                }

                executionTimeLog.Log($"{"****Total Time".PadRight(57)}({lastTick})");

                Trace.PostTraceLog(executionTimeLog);
            }
        }