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 @@
// <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
/// </summary> /// </summary>
void WriteMappings(IEnumerable<NameMapping> mappings); void WriteMappings(IEnumerable<NameMapping> mappings);
/// <summary>
/// Writes an amount of performance counters and the collected values.
/// </summary>
void WritePerformanceCounterData(IEnumerable<PerformanceCounterDescriptor> counters); void WritePerformanceCounterData(IEnumerable<PerformanceCounterDescriptor> counters);
/// <summary>
/// Writes an amount of events.
/// </summary>
void WriteEventData(IEnumerable<EventDataEntry> events); void WriteEventData(IEnumerable<EventDataEntry> events);
/// <summary> /// <summary>

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

@ -12,22 +12,65 @@ using System.Linq;
namespace ICSharpCode.Profiler.Controller.Data 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 public class PerformanceCounterDescriptor
{ {
/// <summary>
/// Gets the category of the performance counter.
/// </summary>
public string Category { get; private set; } public string Category { get; private set; }
/// <summary>
/// Gets the name of the performance counter.
/// </summary>
public string Name { get; private set; } public string Name { get; private set; }
/// <summary>
/// Gets the instance (perfmon process id) of the performance counter.
/// </summary>
public string Instance { get; private set; } public string Instance { get; private set; }
/// <summary>
/// Gets the computer the performance counter is executed on.
/// </summary>
public string Computer { get; private set; } 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; } 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; } 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; } 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; } public string Unit { get; private set; }
/// <summary>
/// Gets the format string for display of the collected values.
/// </summary>
public string Format { get; private set; } public string Format { get; private set; }
float defaultValue; float defaultValue;
PerformanceCounter counter; PerformanceCounter counter;
/// <summary>
/// Creates a new PerformanceCounterDescriptor.
/// </summary>
public PerformanceCounterDescriptor(string category, string name, string instance, string computer, public PerformanceCounterDescriptor(string category, string name, string instance, string computer,
float defaultValue, float? minValue, float? maxValue, string unit, string format) float defaultValue, float? minValue, float? maxValue, string unit, string format)
{ {
@ -43,11 +86,18 @@ namespace ICSharpCode.Profiler.Controller.Data
Format = format; Format = format;
} }
/// <summary>
/// Creates a new PerformanceCounterDescriptor.
/// </summary>
public PerformanceCounterDescriptor(string name, float? minValue, float? maxValue, string unit, string format) public PerformanceCounterDescriptor(string name, float? minValue, float? maxValue, string unit, string format)
: this(null, name, null, null, 0, minValue, maxValue, unit, 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) public static string GetProcessInstanceName(int pid)
{ {
PerformanceCounterCategory cat = new PerformanceCounterCategory("Process"); PerformanceCounterCategory cat = new PerformanceCounterCategory("Process");
@ -64,11 +114,18 @@ namespace ICSharpCode.Profiler.Controller.Data
return null; return null;
} }
/// <summary>
/// Deletes all collected information.
/// </summary>
public void Reset() public void Reset()
{ {
this.Values.Clear(); 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) public void Collect(string instanceName)
{ {
if (counter == null && Instance != null) if (counter == null && Instance != null)
@ -84,25 +141,12 @@ namespace ICSharpCode.Profiler.Controller.Data
} }
} }
/// <summary>
/// Returns the name of the performance counter.
/// </summary>
public override string ToString() public override string ToString()
{ {
return Name; 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
return GetAllCalls(startIndex, endIndex).Where(c => !c.IsThread).MergeByName(); 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(); 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); public abstract float[] GetPerformanceCounterValues(int index);
/// <summary>
/// Returns the list of all events for a dataset.
/// </summary>
public abstract EventDataEntry[] GetEventDataEntries(int index); public abstract EventDataEntry[] GetEventDataEntries(int index);
} }
} }

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save