Browse Source

- Added missing XML Doc.

- Cleaned up file structure.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5199 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 16 years ago
parent
commit
1771eb5595
  1. 63
      src/AddIns/Misc/Profiler/Controller/Data/EventDataEntry.cs
  2. 6
      src/AddIns/Misc/Profiler/Controller/Data/IProfilingDataWriter.cs
  3. 76
      src/AddIns/Misc/Profiler/Controller/Data/PerformanceCounterDescriptor.cs
  4. 9
      src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataProvider.cs
  5. 3
      src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataSQLiteProvider.cs
  6. 6
      src/AddIns/Misc/Profiler/Controller/Data/TempFileDatabase.cs
  7. 3
      src/AddIns/Misc/Profiler/Controller/Data/UnitTestWriter.cs
  8. 1
      src/AddIns/Misc/Profiler/Controller/Profiler.Controller.csproj
  9. 6
      src/AddIns/Misc/Profiler/Controller/ProfilerOptions.cs

63
src/AddIns/Misc/Profiler/Controller/Data/EventDataEntry.cs

@ -0,0 +1,63 @@ @@ -0,0 +1,63 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace ICSharpCode.Profiler.Controller.Data
{
/// <summary>
/// Represents an entry in the list of events collected by the profiler.
/// </summary>
public class EventDataEntry
{
/// <summary>
/// The id of the dataset this entry belongs to.
/// </summary>
public int DataSetId { get; set; }
/// <summary>
/// The type of this event entry.
/// </summary>
public EventType Type { get; set; }
/// <summary>
/// The id of NameMapping of this event entry.
/// </summary>
public int NameId { get; set; }
/// <summary>
/// Additional data collected by the profiler.
/// </summary>
public string Data { get; set; }
}
/// <summary>
/// Defines kinds of events that can be handled by the profiler.
/// </summary>
public enum EventType : int
{
/// <summary>
/// Recorded event was an exception thrown by the profilee.
/// </summary>
Exception = 0,
/// <summary>
/// Recorded event was a call to a Console.Write*/Read* method.
/// </summary>
Console = 1,
/// <summary>
/// Recorded event was fired by Windows Forms controls.
/// </summary>
WindowsForms = 2,
/// <summary>
/// Recorded event was fired by Windows Presentation Foundation controls.
/// </summary>
WindowsPresentationFoundation = 3
}
}

6
src/AddIns/Misc/Profiler/Controller/Data/IProfilingDataWriter.cs

@ -29,8 +29,14 @@ namespace ICSharpCode.Profiler.Controller.Data @@ -29,8 +29,14 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary>
void WriteMappings(IEnumerable<NameMapping> mappings);
/// <summary>
/// Writes an amount of performance counters and the collected values.
/// </summary>
void WritePerformanceCounterData(IEnumerable<PerformanceCounterDescriptor> counters);
/// <summary>
/// Writes an amount of events.
/// </summary>
void WriteEventData(IEnumerable<EventDataEntry> events);
/// <summary>

76
src/AddIns/Misc/Profiler/Controller/Data/PerformanceCounterDescriptor.cs

@ -12,22 +12,65 @@ using System.Linq; @@ -12,22 +12,65 @@ using System.Linq;
namespace ICSharpCode.Profiler.Controller.Data
{
/// <summary>
/// Wraps <see cref="System.Diagnostics.PerformanceCounter" /> to support lazy-loading and easy value collection.
/// Stores additonal meta data such as min/max allowed value or unit of the values.
/// </summary>
public class PerformanceCounterDescriptor
{
/// <summary>
/// Gets the category of the performance counter.
/// </summary>
public string Category { get; private set; }
/// <summary>
/// Gets the name of the performance counter.
/// </summary>
public string Name { get; private set; }
/// <summary>
/// Gets the instance (perfmon process id) of the performance counter.
/// </summary>
public string Instance { get; private set; }
/// <summary>
/// Gets the computer the performance counter is executed on.
/// </summary>
public string Computer { get; private set; }
/// <summary>
/// Gets a list of values collected by this performance counter.
/// </summary>
public IList<float> Values { get; private set; }
/// <summary>
/// Gets the minimum allowed value collected by the performance counter.
/// Returns null if there is no lower bound.
/// </summary>
public float? MinValue { get; private set; }
/// <summary>
/// Gets the maximum allowed value collected by the performance counter.
/// Returns null if there is no upper bound.
/// </summary>
public float? MaxValue { get; private set; }
/// <summary>
/// Gets a string representation of the unit of the values collected.
/// </summary>
public string Unit { get; private set; }
/// <summary>
/// Gets the format string for display of the collected values.
/// </summary>
public string Format { get; private set; }
float defaultValue;
PerformanceCounter counter;
/// <summary>
/// Creates a new PerformanceCounterDescriptor.
/// </summary>
public PerformanceCounterDescriptor(string category, string name, string instance, string computer,
float defaultValue, float? minValue, float? maxValue, string unit, string format)
{
@ -43,11 +86,18 @@ namespace ICSharpCode.Profiler.Controller.Data @@ -43,11 +86,18 @@ namespace ICSharpCode.Profiler.Controller.Data
Format = format;
}
/// <summary>
/// Creates a new PerformanceCounterDescriptor.
/// </summary>
public PerformanceCounterDescriptor(string name, float? minValue, float? maxValue, string unit, string format)
: this(null, name, null, null, 0, minValue, maxValue, unit, format)
{
}
/// <summary>
/// Returns the perfmon process identifier for a process Id.
/// If the process is not available (e. g. not running anymore) null is returned.
/// </summary>
public static string GetProcessInstanceName(int pid)
{
PerformanceCounterCategory cat = new PerformanceCounterCategory("Process");
@ -64,11 +114,18 @@ namespace ICSharpCode.Profiler.Controller.Data @@ -64,11 +114,18 @@ namespace ICSharpCode.Profiler.Controller.Data
return null;
}
/// <summary>
/// Deletes all collected information.
/// </summary>
public void Reset()
{
this.Values.Clear();
}
/// <summary>
/// Collects a new value. The default value is recorded if any error occurs, while attempting to collect a value.
/// </summary>
/// <param name="instanceName"></param>
public void Collect(string instanceName)
{
if (counter == null && Instance != null)
@ -84,25 +141,12 @@ namespace ICSharpCode.Profiler.Controller.Data @@ -84,25 +141,12 @@ namespace ICSharpCode.Profiler.Controller.Data
}
}
/// <summary>
/// Returns the name of the performance counter.
/// </summary>
public override string ToString()
{
return Name;
}
}
public enum EventType : int
{
Exception = 0,
Console = 1,
WindowsForms = 2,
WindowsPresentationFoundation = 3
}
public class EventDataEntry
{
public int DataSetId { get; set; }
public EventType Type { get; set; }
public int NameId { get; set; }
public string Data { get; set; }
}
}

9
src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataProvider.cs

@ -77,10 +77,19 @@ namespace ICSharpCode.Profiler.Controller.Data @@ -77,10 +77,19 @@ namespace ICSharpCode.Profiler.Controller.Data
return GetAllCalls(startIndex, endIndex).Where(c => !c.IsThread).MergeByName();
}
/// <summary>
/// Returns the list of performance counters used in all datasets.
/// </summary>
public abstract PerformanceCounterDescriptor[] GetPerformanceCounters();
/// <summary>
/// Returns the list of all values collected by a performance counter identified by its index.
/// </summary>
public abstract float[] GetPerformanceCounterValues(int index);
/// <summary>
/// Returns the list of all events for a dataset.
/// </summary>
public abstract EventDataEntry[] GetEventDataEntries(int index);
}
}

3
src/AddIns/Misc/Profiler/Controller/Data/ProfilingDataSQLiteProvider.cs

@ -352,6 +352,7 @@ namespace ICSharpCode.Profiler.Controller.Data @@ -352,6 +352,7 @@ namespace ICSharpCode.Profiler.Controller.Data
return query.Where(c => c.NameMapping.Id != 0 && !c.IsThread).MergeByName();
}
/// <inheritdoc/>
public override PerformanceCounterDescriptor[] GetPerformanceCounters()
{
SQLiteCommand cmd;
@ -380,6 +381,7 @@ namespace ICSharpCode.Profiler.Controller.Data @@ -380,6 +381,7 @@ namespace ICSharpCode.Profiler.Controller.Data
}
}
/// <inheritdoc/>
public override float[] GetPerformanceCounterValues(int index)
{
SQLiteCommand cmd;
@ -400,6 +402,7 @@ namespace ICSharpCode.Profiler.Controller.Data @@ -400,6 +402,7 @@ namespace ICSharpCode.Profiler.Controller.Data
}
}
/// <inheritdoc/>
public override EventDataEntry[] GetEventDataEntries(int index)
{
SQLiteCommand cmd;

6
src/AddIns/Misc/Profiler/Controller/Data/TempFileDatabase.cs

@ -39,12 +39,18 @@ namespace ICSharpCode.Profiler.Controller.Data @@ -39,12 +39,18 @@ namespace ICSharpCode.Profiler.Controller.Data
List<PerformanceCounterDescriptor> counters = new List<PerformanceCounterDescriptor>();
/// <summary>
/// Returns the list of performance counters stored in the database.
/// </summary>
public ReadOnlyCollection<PerformanceCounterDescriptor> Counters {
get { return counters.AsReadOnly(); }
}
List<EventDataEntry> events = new List<EventDataEntry>();
/// <summary>
/// Returns the list of events stored in the database.
/// </summary>
public ReadOnlyCollection<EventDataEntry> Events {
get { return events.AsReadOnly(); }
}

3
src/AddIns/Misc/Profiler/Controller/Data/UnitTestWriter.cs

@ -105,16 +105,19 @@ namespace ICSharpCode.Profiler.Controller.Data @@ -105,16 +105,19 @@ namespace ICSharpCode.Profiler.Controller.Data
this.targetWriter.Close();
}
/// <inheritdoc/>
public void WritePerformanceCounterData(IEnumerable<PerformanceCounterDescriptor> counters)
{
this.targetWriter.WritePerformanceCounterData(counters);
}
/// <inheritdoc/>
public void WriteEventData(IEnumerable<EventDataEntry> events)
{
this.targetWriter.WriteEventData(events);
}
/// <inheritdoc/>
public int DataSetCount {
get { return this.targetWriter.DataSetCount; }
}

1
src/AddIns/Misc/Profiler/Controller/Profiler.Controller.csproj

@ -94,6 +94,7 @@ @@ -94,6 +94,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Analysis\IProfilingDataComparer.cs" />
<Compile Include="Data\EventDataEntry.cs" />
<Compile Include="Data\IncompatibleDatabaseException.cs" />
<Compile Include="Data\Linq\AllCalls.cs" />
<Compile Include="Data\Linq\AllFunctions.cs" />

6
src/AddIns/Misc/Profiler/Controller/ProfilerOptions.cs

@ -24,6 +24,9 @@ namespace ICSharpCode.Profiler.Controller @@ -24,6 +24,9 @@ namespace ICSharpCode.Profiler.Controller
/// </summary>
public const int DefaultSharedMemorySize = 64 * 1024 * 1024; // 64 mb
/// <summary>
/// Defines a list of default performance counters.
/// </summary>
public static readonly PerformanceCounterDescriptor[] DefaultCounters = new[] {
new PerformanceCounterDescriptor("Process", "% Processor Time", "_Total", ".", 0, 0, 100, "%", "0.00"),
new PerformanceCounterDescriptor("Process", "IO Data Bytes/sec", "_Total", ".", 0, null, null, "bytes/sec", "#,##0")
@ -37,6 +40,9 @@ namespace ICSharpCode.Profiler.Controller @@ -37,6 +40,9 @@ namespace ICSharpCode.Profiler.Controller
PerformanceCounterDescriptor[] counters;
/// <summary>
/// Gets the performance counters selected for monitoring.
/// </summary>
public PerformanceCounterDescriptor[] Counters {
get { return this.counters; }
}

Loading…
Cancel
Save