diff --git a/.idea/.idea.DiscImageChef/.idea/contentModel.xml b/.idea/.idea.DiscImageChef/.idea/contentModel.xml
index 9f268e80a..4ae3d55dc 100644
--- a/.idea/.idea.DiscImageChef/.idea/contentModel.xml
+++ b/.idea/.idea.DiscImageChef/.idea/contentModel.xml
@@ -1605,6 +1605,8 @@
+
+
diff --git a/DiscImageChef.Gui/Dialogs/dlgBenchmark.xeto b/DiscImageChef.Gui/Dialogs/dlgBenchmark.xeto
new file mode 100644
index 000000000..954dcafc9
--- /dev/null
+++ b/DiscImageChef.Gui/Dialogs/dlgBenchmark.xeto
@@ -0,0 +1,76 @@
+
+
\ No newline at end of file
diff --git a/DiscImageChef.Gui/Dialogs/dlgBenchmark.xeto.cs b/DiscImageChef.Gui/Dialogs/dlgBenchmark.xeto.cs
new file mode 100644
index 000000000..c916abc7c
--- /dev/null
+++ b/DiscImageChef.Gui/Dialogs/dlgBenchmark.xeto.cs
@@ -0,0 +1,187 @@
+// /***************************************************************************
+// The Disc Image Chef
+// ----------------------------------------------------------------------------
+//
+// Filename : dlgBenchmark.xeto.cs
+// Author(s) : Natalia Portillo
+//
+// Component : Benchmark dialog.
+//
+// --[ Description ] ----------------------------------------------------------
+//
+// Implements the benchmark dialog.
+//
+// --[ License ] --------------------------------------------------------------
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General public License for more details.
+//
+// You should have received a copy of the GNU General public License
+// along with this program. If not, see .
+//
+// ----------------------------------------------------------------------------
+// Copyright © 2011-2018 Natalia Portillo
+// ****************************************************************************/
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using DiscImageChef.Core;
+using Eto.Drawing;
+using Eto.Forms;
+using Eto.Serialization.Xaml;
+
+namespace DiscImageChef.Gui.Dialogs
+{
+ public class dlgBenchmark : Dialog
+ {
+ Dictionary checksumTimes;
+ int counter;
+ BenchmarkResults results;
+ int step;
+
+ public dlgBenchmark()
+ {
+ XamlReader.Load(this);
+ }
+
+ protected void OnBtnStart(object sender, EventArgs e)
+ {
+ checksumTimes = new Dictionary();
+ Benchmark.UpdateProgressEvent += UpdateProgress;
+ stkProgress.Visible = true;
+ lblProgress.Text = "";
+ btnClose.Enabled = false;
+ btnStart.Enabled = false;
+ nmuBufferSize.Enabled = false;
+ nmuBlockSize.Enabled = false;
+
+ Thread thread = new Thread(() =>
+ {
+ counter = step = (int)(nmuBufferSize.Value * 1024 * 1024 / nmuBlockSize.Value) % 3333;
+ // TODO: Able to cancel!
+ results = Benchmark.Do((int)(nmuBufferSize.Value * 1024 * 1024), (int)nmuBlockSize.Value);
+
+ Application.Instance.Invoke(Finish);
+ });
+
+ thread.Start();
+ }
+
+ void Finish()
+ {
+ Benchmark.UpdateProgressEvent += UpdateProgress;
+ StackLayout stkCalculationResults = new StackLayout();
+
+ stkCalculationResults.Items.Add(new Label
+ {
+ Text =
+ $"Took {results.FillTime} seconds to fill buffer, {results.FillSpeed:F3} MiB/sec."
+ });
+ stkCalculationResults.Items.Add(new Label
+ {
+ Text =
+ $"Took {results.ReadTime} seconds to read buffer, {results.ReadSpeed:F3} MiB/sec."
+ });
+ stkCalculationResults.Items.Add(new Label
+ {
+ Text =
+ $"Took {results.EntropyTime} seconds to entropy buffer, {results.EntropySpeed:F3} MiB/sec."
+ });
+
+ foreach(KeyValuePair entry in results.Entries)
+ {
+ checksumTimes.Add(entry.Key, entry.Value.TimeSpan);
+ stkCalculationResults.Items.Add(new Label
+ {
+ Text =
+ $"Took {entry.Value.TimeSpan} seconds to {entry.Key} buffer, {entry.Value.Speed:F3} MiB/sec."
+ });
+ ;
+ }
+
+ stkCalculationResults.Items.Add(new Label
+ {
+ Text =
+ $"Took {results.TotalTime} seconds to do all algorithms at the same time, {results.TotalSpeed:F3} MiB/sec."
+ });
+ stkCalculationResults.Items.Add(new Label
+ {
+ Text =
+ $"Took {results.SeparateTime} seconds to do all algorithms sequentially, {results.SeparateSpeed:F3} MiB/sec."
+ });
+ stkCalculationResults.Items.Add(new Label {Text = $"Max memory used is {results.MaxMemory} bytes"});
+ stkCalculationResults.Items.Add(new Label {Text = $"Min memory used is {results.MinMemory} bytes"});
+
+ Statistics.AddCommand("benchmark");
+ Statistics.AddBenchmark(checksumTimes, results.EntropyTime, results.TotalTime, results.SeparateTime,
+ results.MaxMemory, results.MinMemory);
+
+ stkCalculationResults.Items.Add(new StackLayoutItem(stkButtons, HorizontalAlignment.Right, true));
+ stkCalculationResults.Visible = true;
+ btnStart.Visible = false;
+ btnClose.Enabled = true;
+ Content = stkCalculationResults;
+ ClientSize = new Size(-1, -1);
+ }
+
+ void UpdateProgress(string text, long current, long maximum)
+ {
+ if(counter < step)
+ {
+ counter++;
+ return;
+ }
+
+ counter = 0;
+
+ Application.Instance.Invoke(() =>
+ {
+ lblProgress.Text = text;
+
+ if(maximum == 0)
+ {
+ prgProgress.Indeterminate = true;
+ return;
+ }
+
+ if(prgProgress.Indeterminate) prgProgress.Indeterminate = false;
+
+ if(maximum > int.MaxValue || current > int.MaxValue)
+ {
+ prgProgress.MaxValue = (int)(maximum / int.MaxValue);
+ prgProgress.Value = (int)(current / int.MaxValue);
+ }
+ else
+ {
+ prgProgress.MaxValue = (int)maximum;
+ prgProgress.Value = (int)current;
+ }
+ });
+ }
+
+ protected void OnBtnClose(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ #region XAML controls
+ NumericStepper nmuBufferSize;
+ NumericStepper nmuBlockSize;
+ StackLayout stkProgress;
+ Label lblProgress;
+ ProgressBar prgProgress;
+ Button btnStart;
+ Button btnClose;
+ StackLayout stkPreCalculation;
+ StackLayout stkButtons;
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/DiscImageChef.Gui/Forms/frmMain.xeto b/DiscImageChef.Gui/Forms/frmMain.xeto
index f034b9279..5cc7b4bc7 100644
--- a/DiscImageChef.Gui/Forms/frmMain.xeto
+++ b/DiscImageChef.Gui/Forms/frmMain.xeto
@@ -51,6 +51,7 @@
+
diff --git a/DiscImageChef.Gui/Forms/frmMain.xeto.cs b/DiscImageChef.Gui/Forms/frmMain.xeto.cs
index b9ba5f978..361f49c7b 100644
--- a/DiscImageChef.Gui/Forms/frmMain.xeto.cs
+++ b/DiscImageChef.Gui/Forms/frmMain.xeto.cs
@@ -473,6 +473,11 @@ namespace DiscImageChef.Gui.Forms
new dlgEncodings().ShowModal(this);
}
+ protected void OnMenuBenchmark(object sender, EventArgs e)
+ {
+ new dlgBenchmark().ShowModal(this);
+ }
+
protected void OnTreeImagesSelectedItemChanged(object sender, EventArgs e)
{
if(!(sender is TreeGridView tree)) return;
diff --git a/DiscImageChef/Commands/Benchmark.cs b/DiscImageChef/Commands/Benchmark.cs
index dc9981374..4b4196388 100644
--- a/DiscImageChef/Commands/Benchmark.cs
+++ b/DiscImageChef/Commands/Benchmark.cs
@@ -61,9 +61,9 @@ namespace DiscImageChef.Commands
entry.Value.Speed);
}
- DicConsole.WriteLine("Took {0} seconds to do all algorithms at the same time, {1} MiB/sec.",
+ DicConsole.WriteLine("Took {0} seconds to do all algorithms at the same time, {1:F3} MiB/sec.",
results.TotalTime, results.TotalSpeed);
- DicConsole.WriteLine("Took {0} seconds to do all algorithms sequentially, {1} MiB/sec.",
+ DicConsole.WriteLine("Took {0} seconds to do all algorithms sequentially, {1:F3} MiB/sec.",
results.SeparateTime, results.SeparateSpeed);
DicConsole.WriteLine();