Example #1
0
        private void AddPerformanceMeasurement(TableGrid grid, PDFPerformanceMonitorMeasurement measure)
        {
            TableRow row = new TableRow()
            {
                StyleClass = "Debug"
            };

            grid.Rows.Add(row);


            TableCell cell = new TableCell()
            {
                DataStyleIdentifier = "PerfCategoryMeasure"
            };

            cell.Contents.Add(new TextLiteral(measure.Key));
            row.Cells.Add(cell);

            cell = new TableCell()
            {
                DataStyleIdentifier = "PerfCategoryEntryRight"
            };
            cell.Contents.Add(new TextLiteral(measure.Elapsed.TotalMilliseconds.ToString("#,##0.00")));
            row.Cells.Add(cell);

            cell = new TableCell()
            {
                DataStyleIdentifier = "PerfCategoryEntryRight"
            };
            row.Cells.Add(cell);
        }
        /// <summary>
        /// A single encapsulated action that will be recorded in this entry based on the key provided.
        /// NOTE - calls to End and Begin on this entry will affect the results of any Recording until the Recording is stoped (Disposing the instance)
        /// </summary>
        /// <param name="key">The identifier for this measurement. It does not need to be unique, but matching keys will not be aggregated</param>
        /// <returns></returns>
        public IDisposable Record(string key)
        {
            PDFPerformanceMonitorMeasurement indiv = new PDFPerformanceMonitorMeasurement(this, key);

            this.Begin();
            return(indiv);
        }
        //
        // implementation methods
        //



        #region internal int RegisterMeasurement(PDFPerformanceMonitorMeasurement item)

        /// <summary>
        /// Normally called by the measurement itself to ensure it is in this entries list of
        /// measurements, and returns the index of the measurement after it is inserted in the list
        /// </summary>
        /// <param name="item">The measurement item to register</param>
        /// <returns>The index of the item in the list</returns>
        internal int RegisterMeasurement(PDFPerformanceMonitorMeasurement item)
        {
            int count = -1;

            if (this._recordMeasurements)
            {
                if (null == _measurements)
                {
                    _measurements = new List <PDFPerformanceMonitorMeasurement>();
                }
                count = _measurements.Count;
                _measurements.Add(item);
            }
            return(count);
        }