2015-11-30 23:00:47 +00:00
|
|
|
// /***************************************************************************
|
2015-11-27 10:32:54 +00:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Benchmark.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2015-11-27 10:32:54 +00:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : Verbs.
|
2015-11-27 10:32:54 +00:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Implements the 'benchmark' verb.
|
2015-11-27 10:32:54 +00:00
|
|
|
//
|
|
|
|
|
// --[ 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2015-11-27 10:32:54 +00:00
|
|
|
// ****************************************************************************/
|
2016-07-28 18:13:49 +01:00
|
|
|
|
2017-05-27 23:14:55 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using DiscImageChef.Console;
|
2017-12-19 19:33:46 +00:00
|
|
|
using DiscImageChef.Core;
|
2015-11-27 10:32:54 +00:00
|
|
|
|
|
|
|
|
namespace DiscImageChef.Commands
|
|
|
|
|
{
|
2015-11-30 22:28:42 +00:00
|
|
|
public static class Benchmark
|
2015-11-27 10:32:54 +00:00
|
|
|
{
|
2016-04-08 01:13:42 +01:00
|
|
|
public static void doBenchmark(BenchmarkOptions options)
|
2015-11-27 10:32:54 +00:00
|
|
|
{
|
2017-05-27 23:14:55 +01:00
|
|
|
Dictionary<string, double> checksumTimes = new Dictionary<string, double>();
|
2017-05-28 00:31:46 +01:00
|
|
|
Core.Benchmark.InitProgressEvent += Progress.InitProgress;
|
|
|
|
|
Core.Benchmark.UpdateProgressEvent += Progress.UpdateProgress;
|
|
|
|
|
Core.Benchmark.EndProgressEvent += Progress.EndProgress;
|
2017-05-27 23:14:55 +01:00
|
|
|
|
|
|
|
|
BenchmarkResults results = Core.Benchmark.Do(options.BufferSize * 1024 * 1024, options.BlockSize);
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.WriteLine("Took {0} seconds to fill buffer, {1:F3} MiB/sec.", results.fillTime,
|
|
|
|
|
results.fillSpeed);
|
|
|
|
|
DicConsole.WriteLine("Took {0} seconds to read buffer, {1:F3} MiB/sec.", results.readTime,
|
|
|
|
|
results.readSpeed);
|
|
|
|
|
DicConsole.WriteLine("Took {0} seconds to entropy buffer, {1:F3} MiB/sec.", results.entropyTime,
|
|
|
|
|
results.entropySpeed);
|
2017-05-27 23:14:55 +01:00
|
|
|
|
|
|
|
|
foreach(KeyValuePair<string, BenchmarkEntry> entry in results.entries)
|
|
|
|
|
{
|
|
|
|
|
checksumTimes.Add(entry.Key, entry.Value.timeSpan);
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.WriteLine("Took {0} seconds to {1} buffer, {2:F3} MiB/sec.", entry.Value.timeSpan, entry.Key,
|
|
|
|
|
entry.Value.speed);
|
2017-05-27 23:14:55 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
DicConsole.WriteLine("Took {0} seconds to do all algorithms at the same time, {1} MiB/sec.",
|
|
|
|
|
results.totalTime, results.totalSpeed);
|
|
|
|
|
DicConsole.WriteLine("Took {0} seconds to do all algorithms sequentially, {1} MiB/sec.",
|
|
|
|
|
results.separateTime, results.separateSpeed);
|
2017-05-27 23:14:55 +01:00
|
|
|
|
|
|
|
|
DicConsole.WriteLine();
|
|
|
|
|
DicConsole.WriteLine("Max memory used is {0} bytes", results.maxMemory);
|
|
|
|
|
DicConsole.WriteLine("Min memory used is {0} bytes", results.minMemory);
|
|
|
|
|
|
|
|
|
|
Core.Statistics.AddCommand("benchmark");
|
2017-12-19 20:33:03 +00:00
|
|
|
Core.Statistics.AddBenchmark(checksumTimes, results.entropyTime, results.totalTime, results.separateTime,
|
|
|
|
|
results.maxMemory, results.minMemory);
|
2015-11-30 22:28:42 +00:00
|
|
|
}
|
2015-11-27 10:32:54 +00:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|