示例#1
0
        public void Start(string jobId, RowPerformanceTaskNames PerformanceTaskName, int position)
        {
            if (!EyediaCoreConfigurationSection.CurrentConfig.Tracking.PerformanceCounter)
            {
                return;
            }

            if (position > _MaxPerformanceTasks)
            {
                return;
            }

            PerformanceTask            thePerformanceTask  = GetPerformanceTask(jobId);
            PerformanceTaskInformation PerformanceTaskInfo = GetPerformanceTaskSubPerformanceTask(thePerformanceTask, PerformanceTaskName, position);

            if (PerformanceTaskInfo == null)
            {
                PerformanceTaskInfo = new PerformanceTaskInformation(PerformanceTaskName, position);
                thePerformanceTask.RowLevelPerformanceTasks.Add(PerformanceTaskInfo.PerformanceTaskName, PerformanceTaskInfo);
                PerformanceTaskInfo.Start();
            }
            else
            {
                throw new Exception(string.Format("The PerformanceTask '{0}' has already been added", PerformanceTaskName));
            }
        }
示例#2
0
 private PerformanceTaskInformation GetPerformanceTaskSubPerformanceTask(PerformanceTask thePerformanceTask, JobPerformanceTaskNames PerformanceTaskName)
 {
     if ((!(thePerformanceTask.ContainerContainsKey(PerformanceTaskName))) ||
         (IsEverythingOK == false))
     {
         return(null);
     }
     return(thePerformanceTask[PerformanceTaskName]);
 }
示例#3
0
 PerformanceTaskInformation GetPerformanceTaskSubPerformanceTask(PerformanceTask thePerformanceTask, RowPerformanceTaskNames PerformanceTaskName, int position)
 {
     if ((!(thePerformanceTask.ContainsKey(PerformanceTaskName + "|" + position.ToString()))) ||
         (IsEverythingOK == false))
     {
         return(null);
     }
     return(thePerformanceTask[PerformanceTaskName, position]);
 }
示例#4
0
        public void Stop(string jobId, JobPerformanceTaskNames PerformanceTaskName)
        {
            if (!EyediaCoreConfigurationSection.CurrentConfig.Tracking.PerformanceCounter)
            {
                return;
            }

            PerformanceTask            thePerformanceTask  = GetPerformanceTask(jobId);
            PerformanceTaskInformation PerformanceTaskInfo = GetPerformanceTaskSubPerformanceTask(thePerformanceTask, PerformanceTaskName);

            if (PerformanceTaskInfo == null)
            {
                return;
            }

            PerformanceTaskInfo.Stop();
            if (PerformanceTaskName == JobPerformanceTaskNames.WorkerFinalize)
            {
                thePerformanceTask.Stop();
            }
        }
示例#5
0
        public void PrintTrace(string jobId)
        {
            if (EyediaCoreConfigurationSection.CurrentConfig.Tracking.PerformanceCounter)
            {
                ExtensionMethods.TraceInformation("Printing perfromance counters.");
            }
            else
            {
                return;
            }

            if ((!(WorkSheet.ContainsKey(jobId))) ||
                (IsEverythingOK == false))
            {
                ExtensionMethods.TraceInformation("Can not print! Performance counter could not calculate due to some issues. Reset it again for next process.");
                return;
            }

            StringBuilder   sb = new StringBuilder();
            PerformanceTask thePerformanceTask = WorkSheet[jobId] as PerformanceTask;

            if (thePerformanceTask.EndedAt == DateTime.MinValue)
            {
                thePerformanceTask.Stop();
            }

            sb.AppendLine(string.Format("Started at:{0}", thePerformanceTask.StartedAt));

            #region PreValidate

            FormatJobPerformanceTasks(GetPerformanceTaskSubPerformanceTask(thePerformanceTask, JobPerformanceTaskNames.JobInit), sb);
            FormatJobPerformanceTasks(GetPerformanceTaskSubPerformanceTask(thePerformanceTask, JobPerformanceTaskNames.FeedData), sb);
            FormatJobPerformanceTasks(GetPerformanceTaskSubPerformanceTask(thePerformanceTask, JobPerformanceTaskNames.SliceData), sb);
            FormatJobPerformanceTasks(GetPerformanceTaskSubPerformanceTask(thePerformanceTask, JobPerformanceTaskNames.WorkerInit), sb);
            FormatJobPerformanceTasks(GetPerformanceTaskSubPerformanceTask(thePerformanceTask, JobPerformanceTaskNames.PreValidate), sb);

            #endregion PreValidate

            #region Rows

            List <KeyValuePair <int, List <PerformanceTaskNameFormatted> > > aRowList = thePerformanceTask.GetRowLevelPerformanceTaskList();
            sb.AppendLine(GetColumnNames());
            int counter = 0;
            foreach (KeyValuePair <int, List <PerformanceTaskNameFormatted> > item in aRowList)
            {
                List <PerformanceTaskNameFormatted> lst = item.Value.OrderBy(i => i.Position).ToList();

                string   row = string.Empty;
                string[] PerformanceTaskNames = Enum.GetNames(typeof(RowPerformanceTaskNames));
                TimeSpan tsTotalForThisRow    = TimeSpan.Zero;
                foreach (string PerformanceTaskName in PerformanceTaskNames)
                {
                    RowPerformanceTaskNames      thisPerformanceTaskName = (RowPerformanceTaskNames)Enum.Parse(typeof(RowPerformanceTaskNames), PerformanceTaskName);
                    PerformanceTaskNameFormatted tnf = lst.Where(l => l.PerformanceTaskName == thisPerformanceTaskName).SingleOrDefault();
                    row += string.Format("{0},", tnf == null ? "NULL" : tnf.Duration.ToString());
                    if (tnf != null)
                    {
                        tsTotalForThisRow += tnf.Duration;
                    }
                }
                //if (row.Length > 1)
                //    row = row.Substring(0, row.Length - 1);
                row += tsTotalForThisRow.ToString();
                sb.AppendLine(row);
                counter++;
            }

            #endregion Rows

            #region PostValidate

            FormatJobPerformanceTasks(GetPerformanceTaskSubPerformanceTask(thePerformanceTask, JobPerformanceTaskNames.PostValidate), sb);
            FormatJobPerformanceTasks(GetPerformanceTaskSubPerformanceTask(thePerformanceTask, JobPerformanceTaskNames.WorkerFinalize), sb);
            FormatJobPerformanceTasks(GetPerformanceTaskSubPerformanceTask(thePerformanceTask, JobPerformanceTaskNames.ExecuteWorkerManager), sb);
            FormatJobPerformanceTasks(GetPerformanceTaskSubPerformanceTask(thePerformanceTask, JobPerformanceTaskNames.ResultToDataTable), sb);
            FormatJobPerformanceTasks(GetPerformanceTaskSubPerformanceTask(thePerformanceTask, JobPerformanceTaskNames.OutputWriter), sb);

            #endregion PostValidate

            TimeSpan ts         = thePerformanceTask.EndedAt - thePerformanceTask.StartedAt;
            string   formatedTs = string.Format("{0} Days,{1} Hours,{2} Minutes,{3} Seconds, {4} Miliseconds", ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);

            sb.AppendLine(string.Format("Finished at:{0}. Elapsed time:{1} ({2}).", thePerformanceTask.EndedAt, formatedTs, ts.TotalMilliseconds));

            Trace.WriteLine(Environment.NewLine);
            Trace.Write(sb.ToString());
            Trace.WriteLine(Environment.NewLine);
            ExtensionMethods.TraceInformation("Printing perfromance counters. Done!");
            Trace.Flush();
        }