Exemplo n.º 1
0
        /// <summary>
        /// Logs a statistics.
        /// </summary>
        /// <param name="logName">The name of the target log.</param>
        /// <param name="level">The log level used for logging the statistics</param>
        /// <param name="recursive">Bool telling if the log should be recursive, or just display averages.</param>
        /// <param name="statistics">The statistics to be logged</param>
        public static void Log(string logName, LogLevel level, bool recursive, StatisticsSet statistics)
        {
            Platform.Log(logName, level, GetLogString(statistics, recursive));

            foreach (IStatisticsLoggerListener extension in _extensions)
                extension.OnStatisticsLogged(statistics);
        }
Exemplo n.º 2
0
        private static string GetLogString(StatisticsSet statistics, bool recursive)
        {
            XmlElement el = statistics.GetXmlElement(_doc, recursive);

            using (var sw = new StringWriter())
            {
                var settings = new XmlWriterSettings
                {
                    Indent = true,
                    NewLineOnAttributes = false,
                    OmitXmlDeclaration = true,
                    Encoding = Encoding.UTF8
                };

                using (XmlWriter writer = XmlWriter.Create(sw, settings))
                {
                    el.WriteTo(writer);
                    writer.Flush();

                    return sw.ToString();
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Logs a statistics.
 /// </summary>
 /// <param name="logName">The name of the target log.</param>
 /// <param name="level">The log level used for logging the statistics</param>
 /// <param name="statistics">The statistics to be logged</param>
 public static void Log(string logName, LogLevel level, StatisticsSet statistics)
 {
     Log(logName, level, true, statistics);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Logs a statistics.
 /// </summary>
 /// <param name="level">The log level used for logging the statistics</param>
 /// <param name="statistics">The statistics to be logged</param>
 public static void Log(LogLevel level, StatisticsSet statistics)
 {
     Log(level, true, statistics);
 }
Exemplo n.º 5
0
        protected virtual void ComputeAverage(StatisticsSet statistics)
        {
            foreach (IStatistics field in statistics.Fields)
            {
                IAverageStatistics average = field.NewAverageStatistics();

                if (average == null)
                    continue;

                object key = StatisticsHelper.ResolveID(average);
                if (this[key] != null)
                {
                    average = this[key] as IAverageStatistics;
                    Debug.Assert(average != null);
                }
                else
                {
                    AddField(average);
                }

                if (field is Statistics<int>)
                {
                    average.AddSample(((Statistics<int>) field).Value);
                }
                else if (field is Statistics<uint>)
                {
                    average.AddSample(((Statistics<uint>) field).Value);
                }
                else if (field is Statistics<long>)
                {
                    //sum += ((Statistics<long>)field).Value;
                    average.AddSample(((Statistics<long>) field).Value);
                }
                else if (field is Statistics<ulong>)
                {
                    average.AddSample(((Statistics<ulong>) field).Value);
                }
                else if (field is Statistics<double>)
                {
                    average.AddSample(((Statistics<double>) field).Value);
                }
                else if (field is TimeSpanStatistics)
                {
                    TimeSpanStatistics stat = field as TimeSpanStatistics;
                    if (stat.IsSet)
                        average.AddSample(((TimeSpanStatistics) field).Value);
                }
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Adds a sub-statistics.
 /// </summary>
 /// <param name="stat"></param>
 public void AddSubStats(StatisticsSet stat)
 {
     Debug.Assert(stat.Context != null);
     Platform.CheckForNullReference(stat, "stat");
     _subStatistics.Add(stat);
 }