Rewind - add stats for avg stored state size (varies due to delta compression), estimated number of frames that would be stored (with current settings), and est number of minutes (based on est frames vs rewind requency)

This commit is contained in:
adelikat 2013-08-01 21:09:32 +00:00
parent 1faac21e7f
commit 41f8493716
3 changed files with 690 additions and 541 deletions

View File

@ -18,6 +18,7 @@ namespace BizHawk.MultiClient
public float Rewind_FullnessRatio { get { return RewindBuf.FullnessRatio; } }
public int Rewind_Count { get { return RewindBuf.Count; } }
public long Rewind_Size { get { return RewindBuf.Size; } }
/// <summary>
/// Manages a ring buffer of storage which can continually chow its own tail to keep growing forward.
/// Probably only useful for the rewind buffer, so I didnt put it in another file

View File

@ -61,16 +61,22 @@
this.MediumStateSizeLabel = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.RewindIsThreadedCheckbox = new System.Windows.Forms.CheckBox();
this.label4 = new System.Windows.Forms.Label();
this.BufferSizeUpDown = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.DiskBufferCheckbox = new System.Windows.Forms.CheckBox();
this.RewindIsThreadedCheckbox = new System.Windows.Forms.CheckBox();
this.label6 = new System.Windows.Forms.Label();
this.FullnessLabel = new System.Windows.Forms.Label();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.label7 = new System.Windows.Forms.Label();
this.RewindFramesUsedLabel = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.ApproxFramesLabel = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.AverageStoredStateSizeLabel = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.EstTimeLabel = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.LargeSavestateNumeric)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.MediumSavestateNumeric)).BeginInit();
@ -88,7 +94,7 @@
// OK
//
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OK.Location = new System.Drawing.Point(215, 430);
this.OK.Location = new System.Drawing.Point(215, 448);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 0;
@ -100,7 +106,7 @@
//
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(296, 430);
this.Cancel.Location = new System.Drawing.Point(296, 448);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 1;
@ -138,7 +144,7 @@
this.groupBox1.Controls.Add(this.SmallLabel3);
this.groupBox1.Controls.Add(this.SmallSavestateNumeric);
this.groupBox1.Controls.Add(this.SmallLabel1);
this.groupBox1.Location = new System.Drawing.Point(12, 195);
this.groupBox1.Location = new System.Drawing.Point(12, 213);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(359, 118);
this.groupBox1.TabIndex = 3;
@ -223,6 +229,7 @@
0,
0,
0});
this.LargeSavestateNumeric.ValueChanged += new System.EventHandler(this.LargeSavestateNumeric_ValueChanged);
//
// LargeLabel1
//
@ -273,6 +280,7 @@
0,
0,
0});
this.MediumSavestateNumeric.ValueChanged += new System.EventHandler(this.MediumSavestateNumeric_ValueChanged);
//
// MediumLabel1
//
@ -323,6 +331,7 @@
0,
0,
0});
this.SmallSavestateNumeric.ValueChanged += new System.EventHandler(this.SmallSavestateNumeric_ValueChanged);
//
// UseDeltaCompression
//
@ -333,6 +342,7 @@
this.UseDeltaCompression.TabIndex = 4;
this.UseDeltaCompression.Text = "Use delta compression";
this.UseDeltaCompression.UseVisualStyleBackColor = true;
this.UseDeltaCompression.CheckedChanged += new System.EventHandler(this.UseDeltaCompression_CheckedChanged);
//
// label1
//
@ -377,7 +387,7 @@
this.groupBox2.Controls.Add(this.MediumStateSizeLabel);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.MediumStateTrackbar);
this.groupBox2.Location = new System.Drawing.Point(12, 319);
this.groupBox2.Location = new System.Drawing.Point(12, 337);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(359, 105);
this.groupBox2.TabIndex = 8;
@ -489,12 +499,22 @@
this.groupBox3.Controls.Add(this.label3);
this.groupBox3.Controls.Add(this.DiskBufferCheckbox);
this.groupBox3.Controls.Add(this.UseDeltaCompression);
this.groupBox3.Location = new System.Drawing.Point(12, 72);
this.groupBox3.Location = new System.Drawing.Point(12, 90);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(359, 117);
this.groupBox3.TabIndex = 9;
this.groupBox3.TabStop = false;
//
// RewindIsThreadedCheckbox
//
this.RewindIsThreadedCheckbox.AutoSize = true;
this.RewindIsThreadedCheckbox.Location = new System.Drawing.Point(9, 60);
this.RewindIsThreadedCheckbox.Name = "RewindIsThreadedCheckbox";
this.RewindIsThreadedCheckbox.Size = new System.Drawing.Size(111, 17);
this.RewindIsThreadedCheckbox.TabIndex = 17;
this.RewindIsThreadedCheckbox.Text = "Threaded Rewind";
this.RewindIsThreadedCheckbox.UseVisualStyleBackColor = true;
//
// label4
//
this.label4.AutoSize = true;
@ -525,6 +545,7 @@
0,
0,
0});
this.BufferSizeUpDown.ValueChanged += new System.EventHandler(this.BufferSizeUpDown_ValueChanged);
//
// label3
//
@ -545,20 +566,10 @@
this.DiskBufferCheckbox.Text = "Use disk for buffer instead of RAM";
this.DiskBufferCheckbox.UseVisualStyleBackColor = true;
//
// RewindIsThreadedCheckbox
//
this.RewindIsThreadedCheckbox.AutoSize = true;
this.RewindIsThreadedCheckbox.Location = new System.Drawing.Point(9, 60);
this.RewindIsThreadedCheckbox.Name = "RewindIsThreadedCheckbox";
this.RewindIsThreadedCheckbox.Size = new System.Drawing.Size(111, 17);
this.RewindIsThreadedCheckbox.TabIndex = 17;
this.RewindIsThreadedCheckbox.Text = "Threaded Rewind";
this.RewindIsThreadedCheckbox.UseVisualStyleBackColor = true;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(285, 33);
this.label6.Location = new System.Drawing.Point(67, 48);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(26, 13);
this.label6.TabIndex = 10;
@ -567,7 +578,7 @@
// FullnessLabel
//
this.FullnessLabel.AutoSize = true;
this.FullnessLabel.Location = new System.Drawing.Point(312, 33);
this.FullnessLabel.Location = new System.Drawing.Point(94, 48);
this.FullnessLabel.Name = "FullnessLabel";
this.FullnessLabel.Size = new System.Drawing.Size(21, 13);
this.FullnessLabel.TabIndex = 11;
@ -575,6 +586,12 @@
//
// groupBox4
//
this.groupBox4.Controls.Add(this.EstTimeLabel);
this.groupBox4.Controls.Add(this.label11);
this.groupBox4.Controls.Add(this.AverageStoredStateSizeLabel);
this.groupBox4.Controls.Add(this.label9);
this.groupBox4.Controls.Add(this.ApproxFramesLabel);
this.groupBox4.Controls.Add(this.label8);
this.groupBox4.Controls.Add(this.RewindFramesUsedLabel);
this.groupBox4.Controls.Add(this.label7);
this.groupBox4.Controls.Add(this.label1);
@ -583,28 +600,82 @@
this.groupBox4.Controls.Add(this.StateSizeLabel);
this.groupBox4.Location = new System.Drawing.Point(12, 12);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(359, 59);
this.groupBox4.Size = new System.Drawing.Size(359, 72);
this.groupBox4.TabIndex = 12;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Current Statistics";
//
// RewindFramesUsedLabel
//
this.RewindFramesUsedLabel.AutoSize = true;
this.RewindFramesUsedLabel.Location = new System.Drawing.Point(94, 32);
this.RewindFramesUsedLabel.Name = "RewindFramesUsedLabel";
this.RewindFramesUsedLabel.Size = new System.Drawing.Size(13, 13);
this.RewindFramesUsedLabel.TabIndex = 13;
this.RewindFramesUsedLabel.Text = "0";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(233, 17);
this.label7.Location = new System.Drawing.Point(15, 32);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(78, 13);
this.label7.TabIndex = 12;
this.label7.Text = "Frames Stored:";
//
// RewindFramesUsedLabel
// label8
//
this.RewindFramesUsedLabel.AutoSize = true;
this.RewindFramesUsedLabel.Location = new System.Drawing.Point(312, 17);
this.RewindFramesUsedLabel.Name = "RewindFramesUsedLabel";
this.RewindFramesUsedLabel.Size = new System.Drawing.Size(13, 13);
this.RewindFramesUsedLabel.TabIndex = 13;
this.RewindFramesUsedLabel.Text = "0";
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(197, 32);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(66, 13);
this.label8.TabIndex = 14;
this.label8.Text = "Est. storage:";
//
// ApproxFramesLabel
//
this.ApproxFramesLabel.AutoSize = true;
this.ApproxFramesLabel.Location = new System.Drawing.Point(261, 32);
this.ApproxFramesLabel.Name = "ApproxFramesLabel";
this.ApproxFramesLabel.Size = new System.Drawing.Size(47, 13);
this.ApproxFramesLabel.TabIndex = 15;
this.ApproxFramesLabel.Text = "0 frames";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(149, 16);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(114, 13);
this.label9.TabIndex = 16;
this.label9.Text = "Avg Stored State Size:";
//
// AverageStoredStateSizeLabel
//
this.AverageStoredStateSizeLabel.AutoSize = true;
this.AverageStoredStateSizeLabel.Location = new System.Drawing.Point(261, 16);
this.AverageStoredStateSizeLabel.Name = "AverageStoredStateSizeLabel";
this.AverageStoredStateSizeLabel.Size = new System.Drawing.Size(41, 13);
this.AverageStoredStateSizeLabel.TabIndex = 17;
this.AverageStoredStateSizeLabel.Text = "0 bytes";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(209, 48);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(54, 13);
this.label11.TabIndex = 18;
this.label11.Text = "Est. Time:";
//
// EstTimeLabel
//
this.EstTimeLabel.AutoSize = true;
this.EstTimeLabel.Location = new System.Drawing.Point(261, 48);
this.EstTimeLabel.Name = "EstTimeLabel";
this.EstTimeLabel.Size = new System.Drawing.Size(32, 13);
this.EstTimeLabel.TabIndex = 19;
this.EstTimeLabel.Text = "0 min";
//
// RewindConfig
//
@ -612,7 +683,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(383, 465);
this.ClientSize = new System.Drawing.Size(383, 483);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
@ -687,5 +758,11 @@
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Label RewindFramesUsedLabel;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label ApproxFramesLabel;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label AverageStoredStateSizeLabel;
private System.Windows.Forms.Label EstTimeLabel;
private System.Windows.Forms.Label label11;
}
}

View File

@ -9,7 +9,7 @@ namespace BizHawk.MultiClient
private long StateSize;
private int MediumStateSize;
private int LargeStateSize;
private int StateSizeCategory = 1; //1 = small, 2 = med, 3 = larg //TODO: enum
public RewindConfig()
{
InitializeComponent();
@ -74,22 +74,27 @@ namespace BizHawk.MultiClient
if (StateSize >= LargeStateSize)
{
StateSizeCategory = 3;
SmallLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
MediumLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
LargeLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Italic);
}
else if (StateSize >= MediumStateSize)
{
StateSizeCategory = 2;
SmallLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
MediumLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Italic);
LargeLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
}
else
{
StateSizeCategory = 1;
SmallLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Italic);
MediumLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
LargeLabel1.Font = new Font(SmallLabel1.Font, FontStyle.Regular);
}
CalculateEstimates();
}
private void Cancel_Click(object sender, EventArgs e)
@ -235,5 +240,71 @@ namespace BizHawk.MultiClient
LargeStateSize = LargeStateTrackbar.Value * 1024;
SetStateSize();
}
private void CalculateEstimates()
{
long avg_state_size = 0;
if (UseDeltaCompression.Checked)
{
avg_state_size = (long)(Global.MainForm.Rewind_Size / Global.MainForm.Rewind_Count);
}
else
{
avg_state_size = StateSize;
}
long buffer_size = (long)(BufferSizeUpDown.Value);
buffer_size *= 1024 * 1024;
long est_frames = buffer_size / avg_state_size;
long est_frequency = 0;
switch (StateSizeCategory)
{
case 1:
est_frequency = (long)SmallSavestateNumeric.Value;
break;
case 2:
est_frequency = (long)MediumSavestateNumeric.Value;
break;
case 3:
est_frequency = (long)LargeSavestateNumeric.Value;
break;
}
long est_total_frames = est_frames * est_frequency;
double minutes = est_total_frames / 60 / 60;
AverageStoredStateSizeLabel.Text = String.Format("{0:n0}", avg_state_size) + " bytes";
ApproxFramesLabel.Text = String.Format("{0:n0}", est_frames) + " frames";
EstTimeLabel.Text = String.Format("{0:n}", minutes) + " minutes";
}
private void BufferSizeUpDown_ValueChanged(object sender, EventArgs e)
{
CalculateEstimates();
}
private void UseDeltaCompression_CheckedChanged(object sender, EventArgs e)
{
CalculateEstimates();
}
private void SmallSavestateNumeric_ValueChanged(object sender, EventArgs e)
{
CalculateEstimates();
}
private void MediumSavestateNumeric_ValueChanged(object sender, EventArgs e)
{
CalculateEstimates();
}
private void LargeSavestateNumeric_ValueChanged(object sender, EventArgs e)
{
CalculateEstimates();
}
}
}