예제 #1
0
        /// <summary>
        /// Sets the formatting data for <see cref="ProfilerData"/>.
        /// </summary>
        /// <param name="name">The name of the <see cref="ProfilerData"/>.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="description">The description.</param>
        /// <remarks>
        /// <para>
        /// This method allows to specify additional data that is used in the <see cref="DumpAll"/> and
        /// <see cref="Dump()"/> methods.
        /// </para>
        /// <para>
        /// All <see cref="ProfilerData"/> instances with the same name use the same formatting data
        /// (across threads). The data values are multiplied with the <paramref name="scale"/> and the
        /// description is added to the dump output.
        /// </para>
        /// </remarks>
        /// <example>
        /// Here, the profiler data of the method "Foo" is scaled, so that the values are in µs. A
        /// description is set so that the user knows the unit of the displayed values.
        /// <code lang="csharp">
        /// <![CDATA[
        /// Profiler.SetFormat("Foo", 1e6f, "[µs]");
        /// ]]>
        /// </code>
        /// </example>
        public static void SetFormat(string name, double scale, string description)
        {
            lock (((ICollection)Formats).SyncRoot)
            {
                ProfilerDataFormat format;
                if (!Formats.TryGetValue(name, out format))
                {
                    format = new ProfilerDataFormat();
                    Formats.Add(name, format);
                }

                format.Scale       = scale;
                format.Description = description;
            }
        }
예제 #2
0
        /// <summary>
        /// Sets the formatting data for <see cref="ProfilerData"/>.
        /// </summary>
        /// <param name="name">The name of the <see cref="ProfilerData"/>.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="description">The description.</param>
        /// <remarks>
        /// <para>
        /// This method allows to specify additional data that is used in the <see cref="DumpAll"/> and 
        /// <see cref="Dump()"/> methods.
        /// </para>
        /// <para>
        /// All <see cref="ProfilerData"/> instances with the same name use the same formatting data
        /// (across threads). The data values are multiplied with the <paramref name="scale"/> and the
        /// description is added to the dump output. 
        /// </para>
        /// </remarks>
        /// <example>
        /// Here, the profiler data of the method "Foo" is scaled, so that the values are in µs. A
        /// description is set so that the user knows the unit of the displayed values.
        /// <code lang="csharp">
        /// <![CDATA[
        /// Profiler.SetFormat("Foo", 1e6f, "[µs]");
        /// ]]>
        /// </code>
        /// </example>
        public static void SetFormat(string name, double scale, string description)
        {
            lock (((ICollection)Formats).SyncRoot)
              {
            ProfilerDataFormat format;
            if (!Formats.TryGetValue(name, out format))
            {
              format = new ProfilerDataFormat();
              Formats.Add(name, format);
            }

            format.Scale = scale;
            format.Description = description;
              }
        }