Beispiel #1
0
        /// <summary>
        /// Overrides the base behaviour to output one execution summary to the console
        /// </summary>
        /// <param name="summary"></param>
        protected override void DumpAnExecutionSummary(ProfilerExecSummary summary)
        {
            int           index         = 0;
            int           sqllinelength = 70;
            string        front         = string.Format("{0} -> ", summary.ConnectionID);
            string        full          = summary.SQL.Replace('\n', ' ').Replace("\r", "").Replace("\t", "");
            string        padleft       = "".PadLeft(front.Length);//format length of execution id and the colon and space.
            StringBuilder sb            = new StringBuilder();

            sb.Append(front);
            while (index < full.Length)
            {
                if (index > 0)
                {
                    sb.Append(padleft);
                    sb.Append("...");
                }

                if (index + sqllinelength > full.Length)
                {
                    sb.Append(full, index, full.Length - index);
                }
                else
                {
                    sb.Append(full, index, sqllinelength);
                    sb.Append("...");
                }

                if (index == 0)
                {
                    sb.Append("   Exec Count:");
                    sb.Append(summary.ExecCount);
                    if (summary.ExecCount > 1)
                    {
                        sb.Append(", Mean:");
                        sb.Append(summary.MeanDuration);
                        sb.Append(", Min:");
                        sb.Append(summary.MinDuration);
                        sb.Append(", Max:");
                        sb.Append(summary.MaxDuration);
                    }
                    else
                    {
                        sb.Append(", Duration:");
                        sb.Append(summary.MeanDuration);
                    }
                    index         += 3;
                    sqllinelength -= 3;
                }
                sb.Append("\r\n");
                index += sqllinelength;
                //sqllinelength = 100;
            }

            Console.Write(sb.ToString());
            base.DumpAnExecutionSummary(summary);
        }
Beispiel #2
0
        //
        // support methods
        //

        #region private void UpdateExecutionSummary(ProfileData data)

        /// <summary>
        /// Updates a ProfileDataSummary by calling RegisterExecution
        /// </summary>
        /// <param name="data"></param>
        private void UpdateExecutionSummary(ProfilerExecData data)
        {
            ProfilerExecSummary summary;

            if (!_summaries.TryGetSummary(data, out summary))
            {
                lock (_summaryLock)
                {
                    if (!_summaries.TryGetSummary(data, out summary))
                    {
                        summary = new ProfilerExecSummary(data.Connection, data.SQL);
                        _summaries.Add(summary);
                    }
                }
            }
            summary.RegisterExecution(data);
        }
Beispiel #3
0
 /// <summary>
 /// Inheritors should override this method if they wish to
 /// record an summary set of executions against an individual SQL string. Default implementation does nothing
 /// </summary>
 /// <param name="summary"></param>
 protected virtual void DumpAnExecutionSummary(ProfilerExecSummary summary)
 {
     //Inheritors should override, or do nothing
 }