* configurable max. samples

* fixed bug in HistoryManager when more more than 1 item has to be removed

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@911 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2009-03-21 23:51:12 +00:00
parent 53c641fa60
commit daaeeec2f0
8 changed files with 87 additions and 4 deletions
+1
View File
@@ -4,6 +4,7 @@ Process Hacker
* NEW:
* Statistics times in System Information and process properties
* Highlighting system
* Configurable max. samples
* FIXED:
* #2694437 - "Crash when sorting the process list"
* Network connections would be readded if their state changed
@@ -1999,6 +1999,8 @@ namespace ProcessHacker
foreach (string s in Properties.Settings.Default.ImposterNames.Split(','))
Program.ImposterNames.Add(s.Trim());
HistoryManagerGlobal.GlobalMaxCount = Properties.Settings.Default.MaxSamples;
}
public void QueueMessage(string message)
+46 -1
View File
@@ -51,6 +51,8 @@
this.label23 = new System.Windows.Forms.Label();
this.textIconMenuProcesses = new System.Windows.Forms.NumericUpDown();
this.tabAdvanced = new System.Windows.Forms.TabPage();
this.textMaxSamples = new System.Windows.Forms.NumericUpDown();
this.label6 = new System.Windows.Forms.Label();
this.buttonChangeReplaceTaskManager = new System.Windows.Forms.Button();
this.checkReplaceTaskManager = new System.Windows.Forms.CheckBox();
this.checkEnableKPH = new System.Windows.Forms.CheckBox();
@@ -87,6 +89,7 @@
this.tabGeneral.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.textIconMenuProcesses)).BeginInit();
this.tabAdvanced.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.textMaxSamples)).BeginInit();
this.tabHighlighting.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.textHighlightingDuration)).BeginInit();
this.tabPlotting.SuspendLayout();
@@ -125,7 +128,7 @@
this.textUpdateInterval.Size = new System.Drawing.Size(66, 20);
this.textUpdateInterval.TabIndex = 1;
this.textUpdateInterval.Value = new decimal(new int[] {
250,
1000,
0,
0,
0});
@@ -380,6 +383,8 @@
//
// tabAdvanced
//
this.tabAdvanced.Controls.Add(this.textMaxSamples);
this.tabAdvanced.Controls.Add(this.label6);
this.tabAdvanced.Controls.Add(this.buttonChangeReplaceTaskManager);
this.tabAdvanced.Controls.Add(this.checkReplaceTaskManager);
this.tabAdvanced.Controls.Add(this.checkEnableKPH);
@@ -393,6 +398,43 @@
this.tabAdvanced.Text = "Advanced";
this.tabAdvanced.UseVisualStyleBackColor = true;
//
// textMaxSamples
//
this.textMaxSamples.Increment = new decimal(new int[] {
100,
0,
0,
0});
this.textMaxSamples.Location = new System.Drawing.Point(118, 102);
this.textMaxSamples.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.textMaxSamples.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.textMaxSamples.Name = "textMaxSamples";
this.textMaxSamples.Size = new System.Drawing.Size(72, 20);
this.textMaxSamples.TabIndex = 20;
this.textMaxSamples.Value = new decimal(new int[] {
1000,
0,
0,
0});
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(6, 104);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(106, 13);
this.label6.TabIndex = 19;
this.label6.Text = "Max. Sample History:";
this.toolTipProvider.SetToolTip(this.label6, "The number of performance data samples that are retained.");
//
// buttonChangeReplaceTaskManager
//
this.buttonChangeReplaceTaskManager.FlatStyle = System.Windows.Forms.FlatStyle.System;
@@ -767,6 +809,7 @@
((System.ComponentModel.ISupportInitialize)(this.textIconMenuProcesses)).EndInit();
this.tabAdvanced.ResumeLayout(false);
this.tabAdvanced.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.textMaxSamples)).EndInit();
this.tabHighlighting.ResumeLayout(false);
this.tabHighlighting.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.textHighlightingDuration)).EndInit();
@@ -832,5 +875,7 @@
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button buttonChangeReplaceTaskManager;
private System.Windows.Forms.CheckBox checkAllowOnlyOneInstance;
private System.Windows.Forms.NumericUpDown textMaxSamples;
private System.Windows.Forms.Label label6;
}
}
@@ -45,6 +45,7 @@ namespace ProcessHacker
buttonFont.Font = _font;
textUpdateInterval.Value = Properties.Settings.Default.RefreshInterval;
textIconMenuProcesses.Value = Properties.Settings.Default.IconMenuProcessCount;
textMaxSamples.Value = Properties.Settings.Default.MaxSamples;
textSearchEngine.Text = Properties.Settings.Default.SearchEngine;
comboSizeUnits.SelectedItem =
Misc.SizeUnitNames[Properties.Settings.Default.UnitSpecifier];
@@ -254,6 +255,9 @@ namespace ProcessHacker
Properties.Settings.Default.EnableKPH = checkEnableKPH.Checked;
Properties.Settings.Default.ImposterNames = textImposterNames.Text.ToLower();
Properties.Settings.Default.MaxSamples = (int)textMaxSamples.Value;
HistoryManagerGlobal.GlobalMaxCount = Properties.Settings.Default.MaxSamples;
Program.ImposterNames = new System.Collections.Specialized.StringCollection();
foreach (string s in Properties.Settings.Default.ImposterNames.Split(','))
+16 -3
View File
@@ -27,10 +27,21 @@ using System.Text;
namespace ProcessHacker
{
public static class HistoryManagerGlobal
{
private static int _globalMaxCount = 750;
public static int GlobalMaxCount
{
get { return _globalMaxCount; }
set { _globalMaxCount = value; }
}
}
public class HistoryManager<TKey, TValue>
{
private Dictionary<TKey, List<TValue>> _history = new Dictionary<TKey, List<TValue>>();
private int _maxCount = 1000;
private int _maxCount = -1;
public int MaxCount
{
@@ -55,10 +66,12 @@ namespace ProcessHacker
public void Update(TKey key, TValue value)
{
int maxCount = _maxCount == -1 ? HistoryManagerGlobal.GlobalMaxCount : _maxCount;
_history[key].Insert(0, value);
if (_history[key].Count > _maxCount)
_history[key].RemoveRange(_history[key].Count - 1, _history[key].Count - _maxCount);
if (_history[key].Count > maxCount)
_history[key].RemoveRange(maxCount, _history[key].Count - maxCount);
}
}
}
+12
View File
@@ -1164,5 +1164,17 @@ namespace ProcessHacker.Properties {
this["NeedsUpgrade"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("750")]
public int MaxSamples {
get {
return ((int)(this["MaxSamples"]));
}
set {
this["MaxSamples"] = value;
}
}
}
}
@@ -287,5 +287,8 @@
<Setting Name="NeedsUpgrade" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="MaxSamples" Type="System.Int32" Scope="User">
<Value Profile="(Default)">750</Value>
</Setting>
</Settings>
</SettingsFile>
+3
View File
@@ -292,6 +292,9 @@
<setting name="NeedsUpgrade" serializeAs="String">
<value>True</value>
</setting>
<setting name="MaxSamples" serializeAs="String">
<value>750</value>
</setting>
</ProcessHacker.Properties.Settings>
</userSettings>
</configuration>