mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Remove benchmark command.
This commit is contained in:
5
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
5
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -26,7 +26,6 @@
|
||||
<e p="Changelog.md" t="Include" />
|
||||
<e p="DiscImageChef" t="IncludeRecursive">
|
||||
<e p="Commands" t="Include">
|
||||
<e p="Benchmark.cs" t="Include" />
|
||||
<e p="Configure.cs" t="Include" />
|
||||
<e p="Database" t="Include">
|
||||
<e p="DatabaseFamily.cs" t="Include" />
|
||||
@@ -241,7 +240,6 @@
|
||||
</e>
|
||||
</e>
|
||||
<e p="DiscImageChef.Core" t="IncludeRecursive">
|
||||
<e p="Benchmark.cs" t="Include" />
|
||||
<e p="Checksum.cs" t="Include" />
|
||||
<e p="DataFile.cs" t="Include" />
|
||||
<e p="Delegates.cs" t="Include" />
|
||||
@@ -509,6 +507,7 @@
|
||||
<e p="CIS.cs" t="Include" />
|
||||
<e p="Enums.cs" t="Include" />
|
||||
<e p="Types.cs" t="Include" />
|
||||
<e p="Types.cs~" t="Include" />
|
||||
<e p="VendorCode.cs" t="Include" />
|
||||
</e>
|
||||
<e p="SCSI" t="Include">
|
||||
@@ -1811,8 +1810,6 @@
|
||||
<e p="SvgImageView.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Dialogs" t="Include">
|
||||
<e p="dlgBenchmark.xeto" t="Include" />
|
||||
<e p="dlgBenchmark.xeto.cs" t="Include" />
|
||||
<e p="dlgEncodings.xeto" t="Include" />
|
||||
<e p="dlgEncodings.xeto.cs" t="Include" />
|
||||
<e p="dlgPlugins.xeto" t="Include" />
|
||||
|
||||
Submodule DiscImageChef.CommonTypes updated: 02e6c19176...1bd15feee6
Submodule DiscImageChef.Console updated: cf809e896f...700793ae19
@@ -1,583 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Benchmark.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Core algorithms.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Benchmarks DiscImageChef hashing and checksumming speeds.
|
||||
//
|
||||
// --[ 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/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2020 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using DiscImageChef.Checksums;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
|
||||
namespace DiscImageChef.Core
|
||||
{
|
||||
public struct BenchmarkResults
|
||||
{
|
||||
public double FillTime;
|
||||
public double FillSpeed;
|
||||
public double ReadTime;
|
||||
public double ReadSpeed;
|
||||
public double EntropyTime;
|
||||
public double EntropySpeed;
|
||||
public Dictionary<string, BenchmarkEntry> Entries;
|
||||
public long MinMemory;
|
||||
public long MaxMemory;
|
||||
public double SeparateTime;
|
||||
public double SeparateSpeed;
|
||||
public double TotalTime;
|
||||
public double TotalSpeed;
|
||||
}
|
||||
|
||||
public struct BenchmarkEntry
|
||||
{
|
||||
public double TimeSpan;
|
||||
public double Speed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Benchmarks the speed at which we can do checksums
|
||||
/// </summary>
|
||||
public static class Benchmark
|
||||
{
|
||||
public static event InitProgressHandler InitProgressEvent;
|
||||
public static event UpdateProgressHandler UpdateProgressEvent;
|
||||
public static event EndProgressHandler EndProgressEvent;
|
||||
|
||||
static void InitProgress()
|
||||
{
|
||||
InitProgressEvent?.Invoke();
|
||||
}
|
||||
|
||||
static void UpdateProgress(string text, int current, int maximum)
|
||||
{
|
||||
UpdateProgressEvent?.Invoke(string.Format(text, current, maximum), current, maximum);
|
||||
}
|
||||
|
||||
static void EndProgress()
|
||||
{
|
||||
EndProgressEvent?.Invoke();
|
||||
}
|
||||
|
||||
public static BenchmarkResults Do(int bufferSize, int blockSize)
|
||||
{
|
||||
BenchmarkResults results = new BenchmarkResults
|
||||
{
|
||||
Entries = new Dictionary<string, BenchmarkEntry>(),
|
||||
MinMemory = long.MaxValue,
|
||||
MaxMemory = 0,
|
||||
SeparateTime = 0
|
||||
};
|
||||
MemoryStream ms = new MemoryStream(bufferSize);
|
||||
Random rnd = new Random();
|
||||
DateTime start;
|
||||
DateTime end;
|
||||
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Writing block {0} of {1} with random data.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
rnd.NextBytes(tmp);
|
||||
ms.Write(tmp, 0, blockSize);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
end = DateTime.Now;
|
||||
|
||||
results.FillTime = (end - start).TotalSeconds;
|
||||
results.FillSpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds;
|
||||
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
long mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Reading block {0} of {1}.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.ReadTime = (end - start).TotalSeconds;
|
||||
results.ReadSpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds;
|
||||
|
||||
#region Adler32
|
||||
IChecksum ctx = new Adler32Context();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with Adler32.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("Adler32",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion Adler32
|
||||
|
||||
#region Fletcher16
|
||||
ctx = new Fletcher16Context();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with Fletcher-16.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("Fletcher16",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion Fletcher16
|
||||
|
||||
#region Fletcher32
|
||||
ctx = new Fletcher32Context();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with Fletcher-32.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("Fletcher32",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion Fletcher32
|
||||
|
||||
#region CRC16
|
||||
ctx = new Crc16Context();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with CRC16.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("CRC16",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion CRC16
|
||||
|
||||
#region CRC32
|
||||
ctx = new Crc32Context();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with CRC32.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("CRC32",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion CRC32
|
||||
|
||||
#region CRC64
|
||||
ctx = new Crc64Context();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with CRC64.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("CRC64",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion CRC64
|
||||
|
||||
#region MD5
|
||||
ctx = new Md5Context();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with MD5.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("MD5",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion MD5
|
||||
|
||||
#region SHA1
|
||||
ctx = new Sha1Context();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with SHA1.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("SHA1",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion SHA1
|
||||
|
||||
#region SHA256
|
||||
ctx = new Sha256Context();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with SHA256.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("SHA256",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion SHA256
|
||||
|
||||
#region SHA384
|
||||
ctx = new Sha384Context();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with SHA384.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("SHA384",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion SHA384
|
||||
|
||||
#region SHA512
|
||||
ctx = new Sha512Context();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with SHA512.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("SHA512",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion SHA512
|
||||
|
||||
#region SpamSum
|
||||
ctx = new SpamSumContext();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with SpamSum.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
ctx.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
ctx.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.Entries.Add("SpamSum",
|
||||
new BenchmarkEntry
|
||||
{
|
||||
TimeSpan = (end - start).TotalSeconds,
|
||||
Speed = bufferSize / 1048576.0 / (end - start).TotalSeconds
|
||||
});
|
||||
results.SeparateTime += (end - start).TotalSeconds;
|
||||
#endregion SpamSum
|
||||
|
||||
#region Entropy
|
||||
ulong[] entTable = new ulong[256];
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
start = DateTime.Now;
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Entropying block {0} of {1}.", i + 1, bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
foreach(byte b in tmp) entTable[b]++;
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.EntropyTime = (end - start).TotalSeconds;
|
||||
results.EntropySpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds;
|
||||
#endregion Entropy
|
||||
|
||||
/*
|
||||
#region Multitasking
|
||||
start = DateTime.Now;
|
||||
Checksum allChecksums = new Checksum();
|
||||
InitProgress();
|
||||
for(int i = 0; i < bufferSize / blockSize; i++)
|
||||
{
|
||||
UpdateProgress("Checksumming block {0} of {1} with all algorithms at the same time.", i + 1,
|
||||
bufferSize / blockSize);
|
||||
byte[] tmp = new byte[blockSize];
|
||||
ms.Read(tmp, 0, blockSize);
|
||||
|
||||
allChecksums.Update(tmp);
|
||||
}
|
||||
|
||||
EndProgress();
|
||||
|
||||
allChecksums.End();
|
||||
end = DateTime.Now;
|
||||
mem = GC.GetTotalMemory(false);
|
||||
if(mem > results.MaxMemory) results.MaxMemory = mem;
|
||||
if(mem < results.MinMemory) results.MinMemory = mem;
|
||||
|
||||
results.TotalTime = (end - start).TotalSeconds;
|
||||
results.TotalSpeed = bufferSize / 1048576.0 / results.TotalTime;
|
||||
#endregion
|
||||
*/
|
||||
results.SeparateSpeed = bufferSize / 1048576.0 / results.SeparateTime;
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,6 @@
|
||||
<Compile Include="Devices\Dumping\SecureDigital.cs" />
|
||||
<Compile Include="DataFile.cs" />
|
||||
<Compile Include="Filesystems.cs" />
|
||||
<Compile Include="Benchmark.cs" />
|
||||
<Compile Include="Delegates.cs" />
|
||||
<Compile Include="Devices\Scanning\ScanResults.cs" />
|
||||
<Compile Include="Devices\Report\ATA.cs" />
|
||||
|
||||
@@ -86,18 +86,6 @@ namespace DiscImageChef.Core
|
||||
ctx.Commands.Update(command);
|
||||
}
|
||||
|
||||
if(allStats.Commands.Benchmark > 0)
|
||||
{
|
||||
Command command =
|
||||
ctx.Commands.FirstOrDefault(c => c.Name == "benchmark" && c.Synchronized) ?? new Command
|
||||
{
|
||||
Name = "benchmark", Synchronized = true
|
||||
};
|
||||
|
||||
command.Count += (ulong)allStats.Commands.Benchmark;
|
||||
ctx.Commands.Update(command);
|
||||
}
|
||||
|
||||
if(allStats.Commands.Checksum > 0)
|
||||
{
|
||||
Command command =
|
||||
|
||||
Submodule DiscImageChef.Decoders updated: 8eea6af409...785638f5f6
Submodule DiscImageChef.Dto updated: 2f65814ecc...89d1a5fafc
@@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!--
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ============================================================================
|
||||
//
|
||||
// Filename : dlgBenchmark.xeto
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Benchmark dialog.
|
||||
//
|
||||
// ==[ Description ] ==========================================================
|
||||
//
|
||||
// Defines the structure for 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ============================================================================
|
||||
// Copyright © 2011-2020 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
-->
|
||||
<Dialog xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Benchmark" ClientSize="460, 160" Padding="10" Maximizable="False" Minimizable="False" Resizable="False"
|
||||
WindowStyle="None">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Expand="True">
|
||||
|
||||
<StackLayout Orientation="Vertical" ID="stkPreCalculation">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Top">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<NumericStepper ID="nmuBufferSize" Value="128" MinValue="1" MaxValue="1024"/>
|
||||
<Label Text="MiB of buffer"/>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Top">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<NumericStepper ID="nmuBlockSize" Value="512" MinValue="2" MaxValue="65536"/>
|
||||
<Label Text="bytes per block"/>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Expand="True">
|
||||
<StackLayout Orientation="Vertical" ID="stkProgress">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<Label ID="lblProgress" Size="-1, -1"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<ProgressBar ID="prgProgress"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Right" VerticalAlignment="Bottom" Expand="True">
|
||||
<StackLayout Orientation="Horizontal" ID="stkButtons">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<Button ID="btnStart" Click="OnBtnStart">Start</Button>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<Button ID="btnClose" Click="OnBtnClose">Close</Button>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</Dialog>
|
||||
@@ -1,185 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : dlgBenchmark.xeto.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2020 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<string, double> checksumTimes;
|
||||
int counter;
|
||||
BenchmarkResults results;
|
||||
int step;
|
||||
|
||||
public dlgBenchmark()
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
}
|
||||
|
||||
protected void OnBtnStart(object sender, EventArgs e)
|
||||
{
|
||||
checksumTimes = new Dictionary<string, double>();
|
||||
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<string, BenchmarkEntry> 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");
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,6 @@
|
||||
<Label/>
|
||||
<StackLayout Orientation="Vertical" ID="stkStatistics">
|
||||
<CheckBox ID="chkShareStats"/>
|
||||
<CheckBox ID="chkBenchmarkStats"/>
|
||||
<CheckBox ID="chkCommandStats"/>
|
||||
<CheckBox ID="chkDeviceStats"/>
|
||||
<CheckBox ID="chkFilesystemStats"/>
|
||||
|
||||
@@ -47,10 +47,12 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
"In compliance with the European Union General Data Protection Regulation 2016/679 (GDPR),\n" +
|
||||
"we must give you the following information about DiscImageChef and ask if you want to opt-in\n" +
|
||||
"in some information sharing.";
|
||||
|
||||
lblGdpr2.Text =
|
||||
"Disclaimer: Because DiscImageChef is an open source software this information, and therefore,\n" +
|
||||
"compliance with GDPR only holds true if you obtained a certificated copy from its original\n" +
|
||||
"authors. In case of doubt, close DiscImageChef now and ask in our IRC support channel.";
|
||||
|
||||
lblGdpr3.Text =
|
||||
"For any information sharing your IP address may be stored in our server, in a way that is not\n" +
|
||||
"possible for any person, manual, or automated process, to link with your identity, unless\n" +
|
||||
@@ -70,14 +72,16 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
chkSaveReportsGlobally.Text =
|
||||
"Do you want to save device reports in shared folder of your computer? (Y/N): ";
|
||||
|
||||
chkSaveReportsGlobally.Checked = Settings.Settings.Current.SaveReportsGlobally;
|
||||
|
||||
lblShareReports.Text =
|
||||
"Sharing a report with us will send it to our server, that's in the european union territory, where it\n" +
|
||||
"will be manually analized by an european union citizen to remove any trace of personal identification\n" +
|
||||
"from it. Once that is done, it will be shared in our stats website, https://www.discimagechef.app\n" +
|
||||
"from it. Once that is done, it will be shared in our stats website, https://www.discimagechef.app\n" +
|
||||
"These report will be used to improve DiscImageChef support, and in some cases, to provide emulation of the\n" +
|
||||
"devices to other open-source projects. In any case, no information linking the report to you will be stored.";
|
||||
|
||||
chkShareReports.Text = "Do you want to share your device reports with us? (Y/N): ";
|
||||
chkShareReports.Checked = Settings.Settings.Current.ShareReports;
|
||||
#endregion Device reports
|
||||
@@ -88,6 +92,7 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
"command is executed, a filesystem, partition, or device is used, the operating system version, and other.\n" +
|
||||
"In no case, any information besides pure statistical usage numbers is stored, and they're just joint to the\n" +
|
||||
"pool with no way of using them to identify you.";
|
||||
|
||||
chkSaveStats.Text = "Do you want to save stats about your DiscImageChef usage? (Y/N): ";
|
||||
|
||||
if(Settings.Settings.Current.Stats != null)
|
||||
@@ -98,9 +103,6 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
chkShareStats.Text = "Do you want to share your stats anonymously? (Y/N): ";
|
||||
chkShareStats.Checked = Settings.Settings.Current.Stats.ShareStats;
|
||||
|
||||
chkBenchmarkStats.Text = "Do you want to gather statistics about benchmarks? (Y/N): ";
|
||||
chkBenchmarkStats.Checked = Settings.Settings.Current.Stats.BenchmarkStats;
|
||||
|
||||
chkCommandStats.Text = "Do you want to gather statistics about command usage? (Y/N): ";
|
||||
chkCommandStats.Checked = Settings.Settings.Current.Stats.CommandStats;
|
||||
|
||||
@@ -115,6 +117,7 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
chkMediaImageStats.Text =
|
||||
"Do you want to gather statistics about found media image formats? (Y/N): ";
|
||||
|
||||
chkMediaImageStats.Checked = Settings.Settings.Current.Stats.MediaImageStats;
|
||||
|
||||
chkMediaScanStats.Text = "Do you want to gather statistics about scanned media? (Y/N): ";
|
||||
@@ -122,6 +125,7 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
chkPartitionStats.Text =
|
||||
"Do you want to gather statistics about found partitioning schemes? (Y/N): ";
|
||||
|
||||
chkPartitionStats.Checked = Settings.Settings.Current.Stats.PartitionStats;
|
||||
|
||||
chkMediaStats.Text = "Do you want to gather statistics about media types? (Y/N): ";
|
||||
@@ -138,10 +142,7 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
#endregion Statistics
|
||||
}
|
||||
|
||||
protected void OnBtnCancel(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
protected void OnBtnCancel(object sender, EventArgs e) => Close();
|
||||
|
||||
protected void OnBtnSave(object sender, EventArgs e)
|
||||
{
|
||||
@@ -152,18 +153,17 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
Settings.Settings.Current.Stats = new StatsSettings
|
||||
{
|
||||
ShareStats = chkShareStats.Checked == true,
|
||||
BenchmarkStats = chkBenchmarkStats.Checked == true,
|
||||
CommandStats = chkCommandStats.Checked == true,
|
||||
DeviceStats = chkDeviceStats.Checked == true,
|
||||
FilesystemStats = chkFilesystemStats.Checked == true,
|
||||
FilterStats = chkFilterStats.Checked == true,
|
||||
MediaImageStats = chkMediaImageStats.Checked == true,
|
||||
MediaScanStats = chkMediaScanStats.Checked == true,
|
||||
PartitionStats = chkPartitionStats.Checked == true,
|
||||
MediaStats = chkMediaStats.Checked == true,
|
||||
PartitionStats = chkPartitionStats.Checked == true, MediaStats = chkMediaStats.Checked == true,
|
||||
VerifyStats = chkVerifyStats.Checked == true
|
||||
};
|
||||
else Settings.Settings.Current.Stats = null;
|
||||
else
|
||||
Settings.Settings.Current.Stats = null;
|
||||
|
||||
Settings.Settings.Current.GdprCompliance = DicSettings.GdprLevel;
|
||||
Settings.Settings.SaveSettings();
|
||||
@@ -178,7 +178,6 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
CheckBox chkShareReports;
|
||||
CheckBox chkSaveStats;
|
||||
CheckBox chkShareStats;
|
||||
CheckBox chkBenchmarkStats;
|
||||
CheckBox chkCommandStats;
|
||||
CheckBox chkDeviceStats;
|
||||
CheckBox chkFilesystemStats;
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
<TabPage ID="tabCommands" Text="Commands" Visible="False">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<Label ID="lblAnalyze" Visible="False"/>
|
||||
<Label ID="lblBenchmark" Visible="False"/>
|
||||
<Label ID="lblChecksum" Visible="False"/>
|
||||
<Label ID="lblCompare" Visible="False"/>
|
||||
<Label ID="lblConvertImage" Visible="False"/>
|
||||
|
||||
@@ -45,34 +45,26 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
|
||||
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||
var ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
if(ctx.Commands.Any())
|
||||
{
|
||||
if(ctx.Commands.Any(c => c.Name == "analyze"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "analyze" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "analyze" && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "analyze" && !c.Synchronized);
|
||||
|
||||
lblAnalyze.Visible = true;
|
||||
lblAnalyze.Text = $"You have called the Analyze command {count} times";
|
||||
}
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "benchmark"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "benchmark" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "benchmark" && !c.Synchronized);
|
||||
|
||||
lblBenchmark.Visible = true;
|
||||
lblBenchmark.Text = $"You have called the Benchmark command {count} times";
|
||||
}
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "checksum"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "checksum" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "checksum" && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "checksum" && !c.Synchronized);
|
||||
|
||||
lblChecksum.Visible = true;
|
||||
@@ -81,8 +73,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "compare"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "compare" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "compare" && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "compare" && !c.Synchronized);
|
||||
|
||||
lblCompare.Visible = true;
|
||||
@@ -91,8 +84,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "convert-image"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "convert-image" && c.Synchronized)
|
||||
.Select(c => c.Count).FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "convert-image" && c.Synchronized).
|
||||
Select(c => c.Count).FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "convert-image" && !c.Synchronized);
|
||||
|
||||
lblConvertImage.Visible = true;
|
||||
@@ -101,8 +95,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "create-sidecar"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "create-sidecar" && c.Synchronized)
|
||||
.Select(c => c.Count).FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "create-sidecar" && c.Synchronized).
|
||||
Select(c => c.Count).FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "create-sidecar" && !c.Synchronized);
|
||||
|
||||
lblCreateSidecar.Visible = true;
|
||||
@@ -111,8 +106,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "decode"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "decode" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "decode" && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "decode" && !c.Synchronized);
|
||||
|
||||
lblDecode.Visible = true;
|
||||
@@ -121,8 +117,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "device-info"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "device-info" && c.Synchronized)
|
||||
.Select(c => c.Count).FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "device-info" && c.Synchronized).
|
||||
Select(c => c.Count).FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "device-info" && !c.Synchronized);
|
||||
|
||||
lblDeviceInfo.Visible = true;
|
||||
@@ -131,8 +128,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "device-report"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "device-report" && c.Synchronized)
|
||||
.Select(c => c.Count).FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "device-report" && c.Synchronized).
|
||||
Select(c => c.Count).FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "device-report" && !c.Synchronized);
|
||||
|
||||
lblDeviceReport.Visible = true;
|
||||
@@ -141,8 +139,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "dump-media"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "dump-media" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "dump-media" && c.Synchronized).
|
||||
Select(c => c.Count).FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "dump-media" && !c.Synchronized);
|
||||
|
||||
lblDumpMedia.Visible = true;
|
||||
@@ -151,8 +150,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "entropy"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "entropy" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "entropy" && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "entropy" && !c.Synchronized);
|
||||
|
||||
lblEntropy.Visible = true;
|
||||
@@ -161,8 +161,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "formats"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "formats" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "formats" && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "formats" && !c.Synchronized);
|
||||
|
||||
lblFormats.Visible = true;
|
||||
@@ -171,8 +172,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "image-info"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "image-info" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "image-info" && c.Synchronized).
|
||||
Select(c => c.Count).FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "image-info" && !c.Synchronized);
|
||||
|
||||
lblImageInfo.Visible = true;
|
||||
@@ -181,8 +183,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "media-info"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "media-info" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "media-info" && c.Synchronized).
|
||||
Select(c => c.Count).FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "media-info" && !c.Synchronized);
|
||||
|
||||
lblMediaInfo.Visible = true;
|
||||
@@ -191,8 +194,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "media-scan"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "media-scan" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "media-scan" && c.Synchronized).
|
||||
Select(c => c.Count).FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "media-scan" && !c.Synchronized);
|
||||
|
||||
lblMediaScan.Visible = true;
|
||||
@@ -201,8 +205,9 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "printhex"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "printhex" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "printhex" && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "printhex" && !c.Synchronized);
|
||||
|
||||
lblPrintHex.Visible = true;
|
||||
@@ -211,30 +216,38 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
if(ctx.Commands.Any(c => c.Name == "verify"))
|
||||
{
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "verify" && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Commands.Where(c => c.Name == "verify" && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Commands.LongCount(c => c.Name == "verify" && !c.Synchronized);
|
||||
|
||||
lblVerify.Visible = true;
|
||||
lblVerify.Text = $"You have called the Verify command {count} times";
|
||||
}
|
||||
|
||||
tabCommands.Visible = lblAnalyze.Visible || lblBenchmark.Visible || lblChecksum.Visible ||
|
||||
lblCompare.Visible || lblConvertImage.Visible || lblCreateSidecar.Visible ||
|
||||
lblDecode.Visible || lblDeviceInfo.Visible || lblDeviceReport.Visible ||
|
||||
lblDumpMedia.Visible || lblEntropy.Visible || lblFormats.Visible ||
|
||||
lblImageInfo.Visible || lblMediaInfo.Visible || lblMediaScan.Visible ||
|
||||
lblPrintHex.Visible || lblVerify.Visible;
|
||||
tabCommands.Visible = lblAnalyze.Visible || lblChecksum.Visible || lblCompare.Visible ||
|
||||
lblConvertImage.Visible || lblCreateSidecar.Visible || lblDecode.Visible ||
|
||||
lblDeviceInfo.Visible || lblDeviceReport.Visible || lblDumpMedia.Visible ||
|
||||
lblEntropy.Visible || lblFormats.Visible || lblImageInfo.Visible ||
|
||||
lblMediaInfo.Visible || lblMediaScan.Visible || lblPrintHex.Visible ||
|
||||
lblVerify.Visible;
|
||||
}
|
||||
|
||||
if(ctx.Filters.Any())
|
||||
{
|
||||
tabFilters.Visible = true;
|
||||
|
||||
TreeGridItemCollection filterList = new TreeGridItemCollection();
|
||||
var filterList = new TreeGridItemCollection();
|
||||
|
||||
treeFilters.Columns.Add(new GridColumn {HeaderText = "Filter", DataCell = new TextBoxCell(0)});
|
||||
treeFilters.Columns.Add(new GridColumn {HeaderText = "Times found", DataCell = new TextBoxCell(1)});
|
||||
treeFilters.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Filter", DataCell = new TextBoxCell(0)
|
||||
});
|
||||
|
||||
treeFilters.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Times found", DataCell = new TextBoxCell(1)
|
||||
});
|
||||
|
||||
treeFilters.AllowMultipleSelection = false;
|
||||
treeFilters.ShowHeader = true;
|
||||
@@ -242,11 +255,18 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
foreach(string nvs in ctx.Filters.Select(n => n.Name).Distinct())
|
||||
{
|
||||
ulong count = ctx.Filters.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Filters.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Filters.LongCount(c => c.Name == nvs && !c.Synchronized);
|
||||
|
||||
filterList.Add(new TreeGridItem {Values = new object[] {nvs, count}});
|
||||
filterList.Add(new TreeGridItem
|
||||
{
|
||||
Values = new object[]
|
||||
{
|
||||
nvs, count
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,10 +274,17 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
{
|
||||
tabFormats.Visible = true;
|
||||
|
||||
TreeGridItemCollection formatList = new TreeGridItemCollection();
|
||||
var formatList = new TreeGridItemCollection();
|
||||
|
||||
treeFormats.Columns.Add(new GridColumn {HeaderText = "Format", DataCell = new TextBoxCell(0)});
|
||||
treeFormats.Columns.Add(new GridColumn {HeaderText = "Times found", DataCell = new TextBoxCell(1)});
|
||||
treeFormats.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Format", DataCell = new TextBoxCell(0)
|
||||
});
|
||||
|
||||
treeFormats.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Times found", DataCell = new TextBoxCell(1)
|
||||
});
|
||||
|
||||
treeFormats.AllowMultipleSelection = false;
|
||||
treeFormats.ShowHeader = true;
|
||||
@@ -265,11 +292,18 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
foreach(string nvs in ctx.MediaFormats.Select(n => n.Name).Distinct())
|
||||
{
|
||||
ulong count = ctx.MediaFormats.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.MediaFormats.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.MediaFormats.LongCount(c => c.Name == nvs && !c.Synchronized);
|
||||
|
||||
formatList.Add(new TreeGridItem {Values = new object[] {nvs, count}});
|
||||
formatList.Add(new TreeGridItem
|
||||
{
|
||||
Values = new object[]
|
||||
{
|
||||
nvs, count
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,10 +311,17 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
{
|
||||
tabPartitions.Visible = true;
|
||||
|
||||
TreeGridItemCollection partitionList = new TreeGridItemCollection();
|
||||
var partitionList = new TreeGridItemCollection();
|
||||
|
||||
treePartitions.Columns.Add(new GridColumn {HeaderText = "Filter", DataCell = new TextBoxCell(0)});
|
||||
treePartitions.Columns.Add(new GridColumn {HeaderText = "Times found", DataCell = new TextBoxCell(1)});
|
||||
treePartitions.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Filter", DataCell = new TextBoxCell(0)
|
||||
});
|
||||
|
||||
treePartitions.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Times found", DataCell = new TextBoxCell(1)
|
||||
});
|
||||
|
||||
treePartitions.AllowMultipleSelection = false;
|
||||
treePartitions.ShowHeader = true;
|
||||
@@ -288,11 +329,18 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
foreach(string nvs in ctx.Partitions.Select(n => n.Name).Distinct())
|
||||
{
|
||||
ulong count = ctx.Partitions.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Partitions.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Partitions.LongCount(c => c.Name == nvs && !c.Synchronized);
|
||||
|
||||
partitionList.Add(new TreeGridItem {Values = new object[] {nvs, count}});
|
||||
partitionList.Add(new TreeGridItem
|
||||
{
|
||||
Values = new object[]
|
||||
{
|
||||
nvs, count
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,10 +348,17 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
{
|
||||
tabFilesystems.Visible = true;
|
||||
|
||||
TreeGridItemCollection filesystemList = new TreeGridItemCollection();
|
||||
var filesystemList = new TreeGridItemCollection();
|
||||
|
||||
treeFilesystems.Columns.Add(new GridColumn {HeaderText = "Filesystem", DataCell = new TextBoxCell(0)});
|
||||
treeFilesystems.Columns.Add(new GridColumn {HeaderText = "Times found", DataCell = new TextBoxCell(1)});
|
||||
treeFilesystems.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Filesystem", DataCell = new TextBoxCell(0)
|
||||
});
|
||||
|
||||
treeFilesystems.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Times found", DataCell = new TextBoxCell(1)
|
||||
});
|
||||
|
||||
treeFilesystems.AllowMultipleSelection = false;
|
||||
treeFilesystems.ShowHeader = true;
|
||||
@@ -311,11 +366,18 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
foreach(string nvs in ctx.Filesystems.Select(n => n.Name).Distinct())
|
||||
{
|
||||
ulong count = ctx.Filesystems.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Filesystems.Where(c => c.Name == nvs && c.Synchronized).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Filesystems.LongCount(c => c.Name == nvs && !c.Synchronized);
|
||||
|
||||
filesystemList.Add(new TreeGridItem {Values = new object[] {nvs, count}});
|
||||
filesystemList.Add(new TreeGridItem
|
||||
{
|
||||
Values = new object[]
|
||||
{
|
||||
nvs, count
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,35 +385,64 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
{
|
||||
tabDevices.Visible = true;
|
||||
|
||||
TreeGridItemCollection deviceList = new TreeGridItemCollection();
|
||||
var deviceList = new TreeGridItemCollection();
|
||||
|
||||
treeDevices.Columns.Add(new GridColumn {HeaderText = "Device", DataCell = new TextBoxCell(0)});
|
||||
treeDevices.Columns.Add(new GridColumn {HeaderText = "Manufacturer", DataCell = new TextBoxCell(1)});
|
||||
treeDevices.Columns.Add(new GridColumn {HeaderText = "Revision", DataCell = new TextBoxCell(2)});
|
||||
treeDevices.Columns.Add(new GridColumn {HeaderText = "Bus", DataCell = new TextBoxCell(3)});
|
||||
treeDevices.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Device", DataCell = new TextBoxCell(0)
|
||||
});
|
||||
|
||||
treeDevices.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Manufacturer", DataCell = new TextBoxCell(1)
|
||||
});
|
||||
|
||||
treeDevices.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Revision", DataCell = new TextBoxCell(2)
|
||||
});
|
||||
|
||||
treeDevices.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Bus", DataCell = new TextBoxCell(3)
|
||||
});
|
||||
|
||||
treeDevices.AllowMultipleSelection = false;
|
||||
treeDevices.ShowHeader = true;
|
||||
treeDevices.DataStore = deviceList;
|
||||
|
||||
foreach(DeviceStat ds in ctx.SeenDevices.OrderBy(n => n.Manufacturer).ThenBy(n => n.Manufacturer)
|
||||
.ThenBy(n => n.Revision)
|
||||
.ThenBy(n => n.Bus))
|
||||
foreach(DeviceStat ds in ctx.SeenDevices.OrderBy(n => n.Manufacturer).ThenBy(n => n.Manufacturer).
|
||||
ThenBy(n => n.Revision).ThenBy(n => n.Bus))
|
||||
deviceList.Add(new TreeGridItem
|
||||
{
|
||||
Values = new object[] {ds.Model, ds.Manufacturer, ds.Revision, ds.Bus}
|
||||
Values = new object[]
|
||||
{
|
||||
ds.Model, ds.Manufacturer, ds.Revision, ds.Bus
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(!ctx.Medias.Any()) return;
|
||||
if(!ctx.Medias.Any())
|
||||
return;
|
||||
|
||||
tabMedias.Visible = true;
|
||||
|
||||
TreeGridItemCollection mediaList = new TreeGridItemCollection();
|
||||
var mediaList = new TreeGridItemCollection();
|
||||
|
||||
treeMedias.Columns.Add(new GridColumn {HeaderText = "Media", DataCell = new TextBoxCell(0)});
|
||||
treeMedias.Columns.Add(new GridColumn {HeaderText = "Times found", DataCell = new TextBoxCell(1)});
|
||||
treeMedias.Columns.Add(new GridColumn {HeaderText = "Type", DataCell = new TextBoxCell(2)});
|
||||
treeMedias.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Media", DataCell = new TextBoxCell(0)
|
||||
});
|
||||
|
||||
treeMedias.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Times found", DataCell = new TextBoxCell(1)
|
||||
});
|
||||
|
||||
treeMedias.Columns.Add(new GridColumn
|
||||
{
|
||||
HeaderText = "Type", DataCell = new TextBoxCell(2)
|
||||
});
|
||||
|
||||
treeMedias.AllowMultipleSelection = false;
|
||||
treeMedias.ShowHeader = true;
|
||||
@@ -359,31 +450,43 @@ namespace DiscImageChef.Gui.Dialogs
|
||||
|
||||
foreach(string media in ctx.Medias.OrderBy(ms => ms.Type).Select(ms => ms.Type).Distinct())
|
||||
{
|
||||
ulong count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && c.Real).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
ulong count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && c.Real).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count += (ulong)ctx.Medias.LongCount(c => c.Type == media && !c.Synchronized && c.Real);
|
||||
|
||||
if(count > 0) mediaList.Add(new TreeGridItem {Values = new object[] {media, count, "real"}});
|
||||
if(count > 0)
|
||||
mediaList.Add(new TreeGridItem
|
||||
{
|
||||
Values = new object[]
|
||||
{
|
||||
media, count, "real"
|
||||
}
|
||||
});
|
||||
|
||||
count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && !c.Real).Select(c => c.Count).
|
||||
FirstOrDefault();
|
||||
|
||||
count = ctx.Medias.Where(c => c.Type == media && c.Synchronized && !c.Real).Select(c => c.Count)
|
||||
.FirstOrDefault();
|
||||
count += (ulong)ctx.Medias.LongCount(c => c.Type == media && !c.Synchronized && !c.Real);
|
||||
|
||||
if(count == 0) continue;
|
||||
if(count == 0)
|
||||
continue;
|
||||
|
||||
mediaList.Add(new TreeGridItem {Values = new object[] {media, count, "image"}});
|
||||
mediaList.Add(new TreeGridItem
|
||||
{
|
||||
Values = new object[]
|
||||
{
|
||||
media, count, "image"
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnBtnClose(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
protected void OnBtnClose(object sender, EventArgs e) => Close();
|
||||
|
||||
#region XAML controls
|
||||
TabPage tabCommands;
|
||||
Label lblAnalyze;
|
||||
Label lblBenchmark;
|
||||
Label lblChecksum;
|
||||
Label lblCompare;
|
||||
Label lblConvertImage;
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
<ButtonMenuItem Text="&Console" Click="OnMenuConsole"/>
|
||||
</ButtonMenuItem>
|
||||
<ButtonMenuItem Text="&Help">
|
||||
<ButtonMenuItem Text="&Benchmark" Click="OnMenuBenchmark"/>
|
||||
<ButtonMenuItem Text="&Encodings" Click="OnMenuEncodings"/>
|
||||
<ButtonMenuItem Text="&Plugins" Click="OnMenuPlugins"/>
|
||||
<ButtonMenuItem Text="&Statistics" Click="OnMenuStatistics"/>
|
||||
|
||||
@@ -58,10 +58,8 @@ namespace DiscImageChef.Gui.Forms
|
||||
{
|
||||
public class frmMain : Form
|
||||
{
|
||||
bool closing;
|
||||
readonly Bitmap devicesIcon;
|
||||
readonly Bitmap ejectIcon;
|
||||
GridView grdFiles;
|
||||
readonly Bitmap hardDiskIcon;
|
||||
readonly Bitmap imagesIcon;
|
||||
readonly Label lblError;
|
||||
@@ -72,10 +70,12 @@ namespace DiscImageChef.Gui.Forms
|
||||
readonly Bitmap removableIcon;
|
||||
readonly Bitmap sdIcon;
|
||||
readonly Bitmap tapeIcon;
|
||||
TreeGridView treeImages;
|
||||
readonly TreeGridItemCollection treeImagesItems;
|
||||
readonly ContextMenu treeImagesMenu;
|
||||
readonly Bitmap usbIcon;
|
||||
bool closing;
|
||||
GridView grdFiles;
|
||||
TreeGridView treeImages;
|
||||
|
||||
public frmMain(bool debug, bool verbose)
|
||||
{
|
||||
@@ -693,8 +693,6 @@ namespace DiscImageChef.Gui.Forms
|
||||
|
||||
protected void OnMenuEncodings(object sender, EventArgs e) => new dlgEncodings().ShowModal(this);
|
||||
|
||||
protected void OnMenuBenchmark(object sender, EventArgs e) => new dlgBenchmark().ShowModal(this);
|
||||
|
||||
protected void OnMenuStatistics(object sender, EventArgs e)
|
||||
{
|
||||
var ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||
|
||||
Submodule DiscImageChef.Helpers updated: d0b9780be9...0fb1781ca2
@@ -40,99 +40,61 @@ using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID;
|
||||
|
||||
namespace DiscImageChef.Settings
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings
|
||||
/// </summary>
|
||||
/// <summary>Settings</summary>
|
||||
public class DicSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Level for GDPR compliance checking. Every time a new feature may share user information this level should go up,
|
||||
/// and the user asked to opt-in.
|
||||
/// Level for GDPR compliance checking. Every time a new feature may share user information this level should go
|
||||
/// up, and the user asked to opt-in.
|
||||
/// </summary>
|
||||
public const ulong GdprLevel = 1;
|
||||
/// <summary>
|
||||
/// Set of GDPR compliance, if lower than <see cref="GdprLevel" />, ask user for compliance.
|
||||
/// </summary>
|
||||
/// <summary>Set of GDPR compliance, if lower than <see cref="GdprLevel" />, ask user for compliance.</summary>
|
||||
public ulong GdprCompliance;
|
||||
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, reports will be saved locally
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, reports will be saved locally</summary>
|
||||
public bool SaveReportsGlobally;
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, reports will be sent to DiscImageChef.Server
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, reports will be sent to DiscImageChef.Server</summary>
|
||||
public bool ShareReports;
|
||||
/// <summary>
|
||||
/// Statistics
|
||||
/// </summary>
|
||||
/// <summary>Statistics</summary>
|
||||
public StatsSettings Stats;
|
||||
}
|
||||
|
||||
// TODO: Use this
|
||||
/// <summary>
|
||||
/// User settings, for media dumps, completely unused
|
||||
/// </summary>
|
||||
/// <summary>User settings, for media dumps, completely unused</summary>
|
||||
public class UserSettings
|
||||
{
|
||||
public string Email;
|
||||
public string Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Statistics settings
|
||||
/// </summary>
|
||||
/// <summary>Statistics settings</summary>
|
||||
public class StatsSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, benchmark statistics will be stored
|
||||
/// </summary>
|
||||
public bool BenchmarkStats;
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, command usage statistics will be stored
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, benchmark statistics will be stored</summary>
|
||||
public bool BenchmarkStats = false;
|
||||
/// <summary>If set to <c>true</c>, command usage statistics will be stored</summary>
|
||||
public bool CommandStats;
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, device statistics will be stored
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, device statistics will be stored</summary>
|
||||
public bool DeviceStats;
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, filesystem statistics will be stored
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, filesystem statistics will be stored</summary>
|
||||
public bool FilesystemStats;
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, filters statistics will be stored
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, filters statistics will be stored</summary>
|
||||
public bool FilterStats;
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, dump media images statistics will be stored
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, dump media images statistics will be stored</summary>
|
||||
public bool MediaImageStats;
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, media scan statistics will be stored
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, media scan statistics will be stored</summary>
|
||||
public bool MediaScanStats;
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, media types statistics will be stored
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, media types statistics will be stored</summary>
|
||||
public bool MediaStats;
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, partition schemes statistics will be stored
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, partition schemes statistics will be stored</summary>
|
||||
public bool PartitionStats;
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, statistics will be sent to DiscImageChef.Server
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, statistics will be sent to DiscImageChef.Server</summary>
|
||||
public bool ShareStats;
|
||||
/// <summary>
|
||||
/// If set to <c>true</c>, dump media verification statistics will be stored
|
||||
/// </summary>
|
||||
/// <summary>If set to <c>true</c>, dump media verification statistics will be stored</summary>
|
||||
public bool VerifyStats;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manages statistics
|
||||
/// </summary>
|
||||
/// <summary>Manages statistics</summary>
|
||||
public static class Settings
|
||||
{
|
||||
const string XDG_DATA_HOME = "XDG_DATA_HOME";
|
||||
@@ -140,27 +102,19 @@ namespace DiscImageChef.Settings
|
||||
const string OLD_DATA_HOME = ".claunia.com";
|
||||
const string XDG_DATA_HOME_RESOLVED = ".local/share";
|
||||
const string XDG_CONFIG_HOME_RESOLVED = ".config";
|
||||
/// <summary>
|
||||
/// Current statistcs
|
||||
/// </summary>
|
||||
/// <summary>Current statistcs</summary>
|
||||
public static DicSettings Current;
|
||||
|
||||
/// <summary>
|
||||
/// Global path to save reports
|
||||
/// </summary>
|
||||
/// <summary>Global path to save reports</summary>
|
||||
static string ReportsPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Global path to save statistics
|
||||
/// </summary>
|
||||
/// <summary>Global path to save statistics</summary>
|
||||
public static string StatsPath { get; private set; }
|
||||
|
||||
public static string LocalDbPath { get; private set; }
|
||||
public static string MasterDbPath { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Loads settings
|
||||
/// </summary>
|
||||
/// <summary>Loads settings</summary>
|
||||
public static void LoadSettings()
|
||||
{
|
||||
Current = new DicSettings();
|
||||
@@ -180,21 +134,31 @@ namespace DiscImageChef.Settings
|
||||
string appSupportPath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library",
|
||||
"Application Support", "Claunia.com");
|
||||
if(!Directory.Exists(appSupportPath)) Directory.CreateDirectory(appSupportPath);
|
||||
|
||||
if(!Directory.Exists(appSupportPath))
|
||||
Directory.CreateDirectory(appSupportPath);
|
||||
|
||||
string dicPath = Path.Combine(appSupportPath, "DiscImageChef");
|
||||
if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath);
|
||||
|
||||
if(!Directory.Exists(dicPath))
|
||||
Directory.CreateDirectory(dicPath);
|
||||
|
||||
LocalDbPath = Path.Combine(dicPath, LocalDbPath);
|
||||
MasterDbPath = Path.Combine(dicPath, MasterDbPath);
|
||||
|
||||
ReportsPath = Path.Combine(dicPath, "Reports");
|
||||
if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath);
|
||||
|
||||
if(!Directory.Exists(ReportsPath))
|
||||
Directory.CreateDirectory(ReportsPath);
|
||||
|
||||
StatsPath = Path.Combine(dicPath, "Statistics");
|
||||
if(!Directory.Exists(StatsPath)) Directory.CreateDirectory(StatsPath);
|
||||
|
||||
if(!Directory.Exists(StatsPath))
|
||||
Directory.CreateDirectory(StatsPath);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// In case of Windows statistics and reports will be saved in %APPDATA%\Claunia.com\DiscImageChef
|
||||
case PlatformID.Win32NT:
|
||||
case PlatformID.Win32S:
|
||||
@@ -205,21 +169,31 @@ namespace DiscImageChef.Settings
|
||||
string appSupportPath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"Claunia.com");
|
||||
if(!Directory.Exists(appSupportPath)) Directory.CreateDirectory(appSupportPath);
|
||||
|
||||
if(!Directory.Exists(appSupportPath))
|
||||
Directory.CreateDirectory(appSupportPath);
|
||||
|
||||
string dicPath = Path.Combine(appSupportPath, "DiscImageChef");
|
||||
if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath);
|
||||
|
||||
if(!Directory.Exists(dicPath))
|
||||
Directory.CreateDirectory(dicPath);
|
||||
|
||||
LocalDbPath = Path.Combine(dicPath, LocalDbPath);
|
||||
MasterDbPath = Path.Combine(dicPath, MasterDbPath);
|
||||
|
||||
ReportsPath = Path.Combine(dicPath, "Reports");
|
||||
if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath);
|
||||
|
||||
if(!Directory.Exists(ReportsPath))
|
||||
Directory.CreateDirectory(ReportsPath);
|
||||
|
||||
StatsPath = Path.Combine(dicPath, "Statistics");
|
||||
if(!Directory.Exists(StatsPath)) Directory.CreateDirectory(StatsPath);
|
||||
|
||||
if(!Directory.Exists(StatsPath))
|
||||
Directory.CreateDirectory(StatsPath);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// Otherwise, statistics and reports will be saved in ~/.claunia.com/DiscImageChef
|
||||
default:
|
||||
{
|
||||
@@ -227,30 +201,40 @@ namespace DiscImageChef.Settings
|
||||
Path.Combine(homePath,
|
||||
Environment.GetEnvironmentVariable(XDG_DATA_HOME) ?? XDG_DATA_HOME_RESOLVED);
|
||||
|
||||
string oldDicPath = Path.Combine(homePath, ".claunia.com", "DiscImageChef");
|
||||
string oldDicPath = Path.Combine(homePath, ".claunia.com", "DiscImageChef");
|
||||
string dicPath = Path.Combine(xdgDataPath, "DiscImageChef");
|
||||
|
||||
if(Directory.Exists(oldDicPath) && !Directory.Exists(dicPath))
|
||||
if(Directory.Exists(oldDicPath) &&
|
||||
!Directory.Exists(dicPath))
|
||||
{
|
||||
Directory.Move(oldDicPath, dicPath);
|
||||
Directory.Delete(Path.Combine(homePath, ".claunia.com"));
|
||||
}
|
||||
|
||||
if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath);
|
||||
if(!Directory.Exists(dicPath))
|
||||
Directory.CreateDirectory(dicPath);
|
||||
|
||||
LocalDbPath = Path.Combine(dicPath, LocalDbPath);
|
||||
MasterDbPath = Path.Combine(dicPath, MasterDbPath);
|
||||
|
||||
ReportsPath = Path.Combine(dicPath, "Reports");
|
||||
if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath);
|
||||
|
||||
if(!Directory.Exists(ReportsPath))
|
||||
Directory.CreateDirectory(ReportsPath);
|
||||
|
||||
StatsPath = Path.Combine(dicPath, "Statistics");
|
||||
if(!Directory.Exists(StatsPath)) Directory.CreateDirectory(StatsPath);
|
||||
|
||||
if(!Directory.Exists(StatsPath))
|
||||
Directory.CreateDirectory(StatsPath);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch { ReportsPath = null; }
|
||||
catch
|
||||
{
|
||||
ReportsPath = null;
|
||||
}
|
||||
|
||||
FileStream prefsFs = null;
|
||||
StreamReader prefsSr = null;
|
||||
@@ -266,6 +250,7 @@ namespace DiscImageChef.Settings
|
||||
string preferencesPath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library",
|
||||
"Preferences");
|
||||
|
||||
string preferencesFilePath = Path.Combine(preferencesPath, "com.claunia.discimagechef.plist");
|
||||
|
||||
if(!File.Exists(preferencesFilePath))
|
||||
@@ -276,7 +261,8 @@ namespace DiscImageChef.Settings
|
||||
|
||||
prefsFs = new FileStream(preferencesFilePath, FileMode.Open, FileAccess.Read);
|
||||
|
||||
NSDictionary parsedPreferences = (NSDictionary)BinaryPropertyListParser.Parse(prefsFs);
|
||||
var parsedPreferences = (NSDictionary)BinaryPropertyListParser.Parse(prefsFs);
|
||||
|
||||
if(parsedPreferences != null)
|
||||
{
|
||||
Current.SaveReportsGlobally =
|
||||
@@ -288,47 +274,38 @@ namespace DiscImageChef.Settings
|
||||
|
||||
if(parsedPreferences.TryGetValue("Stats", out obj))
|
||||
{
|
||||
NSDictionary stats = (NSDictionary)obj;
|
||||
var stats = (NSDictionary)obj;
|
||||
|
||||
if(stats != null)
|
||||
Current.Stats = new StatsSettings
|
||||
{
|
||||
ShareStats =
|
||||
stats.TryGetValue("ShareStats", out NSObject obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
BenchmarkStats =
|
||||
stats.TryGetValue("BenchmarkStats", out obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
CommandStats =
|
||||
stats.TryGetValue("CommandStats", out obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
DeviceStats =
|
||||
stats.TryGetValue("DeviceStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||
ShareStats = stats.TryGetValue("ShareStats", out NSObject obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
CommandStats = stats.TryGetValue("CommandStats", out obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
DeviceStats = stats.TryGetValue("DeviceStats", out obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
FilesystemStats =
|
||||
stats.TryGetValue("FilesystemStats", out obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
FilterStats =
|
||||
stats.TryGetValue("FilterStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||
stats.TryGetValue("FilesystemStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||
FilterStats = stats.TryGetValue("FilterStats", out obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
MediaImageStats =
|
||||
stats.TryGetValue("MediaImageStats", out obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
stats.TryGetValue("MediaImageStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||
MediaScanStats =
|
||||
stats.TryGetValue("MediaScanStats", out obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
stats.TryGetValue("MediaScanStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||
PartitionStats =
|
||||
stats.TryGetValue("PartitionStats", out obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
MediaStats =
|
||||
stats.TryGetValue("MediaStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||
VerifyStats =
|
||||
stats.TryGetValue("VerifyStats", out obj2) && ((NSNumber)obj2).ToBool()
|
||||
stats.TryGetValue("PartitionStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||
MediaStats = stats.TryGetValue("MediaStats", out obj2) &&
|
||||
((NSNumber)obj2).ToBool(),
|
||||
VerifyStats = stats.TryGetValue("VerifyStats", out obj2) &&
|
||||
((NSNumber)obj2).ToBool()
|
||||
};
|
||||
}
|
||||
else Current.Stats = null;
|
||||
else
|
||||
Current.Stats = null;
|
||||
|
||||
Current.GdprCompliance = parsedPreferences.TryGetValue("GdprCompliance", out obj)
|
||||
? (ulong)((NSNumber)obj).ToLong()
|
||||
: 0;
|
||||
? (ulong)((NSNumber)obj).ToLong() : 0;
|
||||
|
||||
prefsFs.Close();
|
||||
}
|
||||
@@ -340,8 +317,10 @@ namespace DiscImageChef.Settings
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
#if !NETSTANDARD2_0
|
||||
#if !NETSTANDARD2_0
|
||||
|
||||
// In case of Windows settings will be saved in the registry: HKLM/SOFTWARE/Claunia.com/DiscImageChef
|
||||
case PlatformID.Win32NT:
|
||||
case PlatformID.Win32S:
|
||||
@@ -350,18 +329,22 @@ namespace DiscImageChef.Settings
|
||||
case PlatformID.WindowsPhone:
|
||||
{
|
||||
RegistryKey parentKey = Registry.CurrentUser.OpenSubKey("SOFTWARE")?.OpenSubKey("Claunia.com");
|
||||
|
||||
if(parentKey == null)
|
||||
{
|
||||
SetDefaultSettings();
|
||||
SaveSettings();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RegistryKey key = parentKey.OpenSubKey("DiscImageChef");
|
||||
|
||||
if(key == null)
|
||||
{
|
||||
SetDefaultSettings();
|
||||
SaveSettings();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -370,11 +353,11 @@ namespace DiscImageChef.Settings
|
||||
Current.GdprCompliance = Convert.ToUInt64(key.GetValue("GdprCompliance"));
|
||||
|
||||
bool stats = Convert.ToBoolean(key.GetValue("Statistics"));
|
||||
|
||||
if(stats)
|
||||
Current.Stats = new StatsSettings
|
||||
{
|
||||
ShareStats = Convert.ToBoolean(key.GetValue("ShareStats")),
|
||||
BenchmarkStats = Convert.ToBoolean(key.GetValue("BenchmarkStats")),
|
||||
CommandStats = Convert.ToBoolean(key.GetValue("CommandStats")),
|
||||
DeviceStats = Convert.ToBoolean(key.GetValue("DeviceStats")),
|
||||
FilesystemStats = Convert.ToBoolean(key.GetValue("FilesystemStats")),
|
||||
@@ -388,23 +371,29 @@ namespace DiscImageChef.Settings
|
||||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Otherwise, settings will be saved in ~/.config/DiscImageChef.xml
|
||||
default:
|
||||
{
|
||||
string oldConfigPath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config");
|
||||
|
||||
string oldSettingsPath = Path.Combine(oldConfigPath, "DiscImageChef.xml");
|
||||
|
||||
string xdgConfigPath =
|
||||
Path.Combine(homePath,
|
||||
Environment.GetEnvironmentVariable(XDG_CONFIG_HOME) ??
|
||||
XDG_CONFIG_HOME_RESOLVED);
|
||||
|
||||
string settingsPath = Path.Combine(xdgConfigPath, "DiscImageChef.xml");
|
||||
|
||||
if(File.Exists(oldSettingsPath) && !File.Exists(settingsPath))
|
||||
if(File.Exists(oldSettingsPath) &&
|
||||
!File.Exists(settingsPath))
|
||||
{
|
||||
if(!Directory.Exists(xdgConfigPath)) Directory.CreateDirectory(xdgConfigPath);
|
||||
if(!Directory.Exists(xdgConfigPath))
|
||||
Directory.CreateDirectory(xdgConfigPath);
|
||||
|
||||
File.Move(oldSettingsPath, settingsPath);
|
||||
}
|
||||
|
||||
@@ -412,10 +401,11 @@ namespace DiscImageChef.Settings
|
||||
{
|
||||
SetDefaultSettings();
|
||||
SaveSettings();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
XmlSerializer xs = new XmlSerializer(Current.GetType());
|
||||
var xs = new XmlSerializer(Current.GetType());
|
||||
prefsSr = new StreamReader(settingsPath);
|
||||
Current = (DicSettings)xs.Deserialize(prefsSr);
|
||||
}
|
||||
@@ -444,42 +434,72 @@ namespace DiscImageChef.Settings
|
||||
case PlatformID.MacOSX:
|
||||
case PlatformID.iOS:
|
||||
{
|
||||
NSDictionary root = new NSDictionary
|
||||
var root = new NSDictionary
|
||||
{
|
||||
{"SaveReportsGlobally", Current.SaveReportsGlobally},
|
||||
{"ShareReports", Current.ShareReports},
|
||||
{"GdprCompliance", Current.GdprCompliance}
|
||||
{
|
||||
"SaveReportsGlobally", Current.SaveReportsGlobally
|
||||
},
|
||||
{
|
||||
"ShareReports", Current.ShareReports
|
||||
},
|
||||
{
|
||||
"GdprCompliance", Current.GdprCompliance
|
||||
}
|
||||
};
|
||||
|
||||
if(Current.Stats != null)
|
||||
{
|
||||
NSDictionary stats = new NSDictionary
|
||||
var stats = new NSDictionary
|
||||
{
|
||||
{"ShareStats", Current.Stats.ShareStats},
|
||||
{"BenchmarkStats", Current.Stats.BenchmarkStats},
|
||||
{"CommandStats", Current.Stats.CommandStats},
|
||||
{"DeviceStats", Current.Stats.DeviceStats},
|
||||
{"FilesystemStats", Current.Stats.FilesystemStats},
|
||||
{"FilterStats", Current.Stats.FilterStats},
|
||||
{"MediaImageStats", Current.Stats.MediaImageStats},
|
||||
{"MediaScanStats", Current.Stats.MediaScanStats},
|
||||
{"PartitionStats", Current.Stats.PartitionStats},
|
||||
{"MediaStats", Current.Stats.MediaStats},
|
||||
{"VerifyStats", Current.Stats.VerifyStats}
|
||||
{
|
||||
"ShareStats", Current.Stats.ShareStats
|
||||
},
|
||||
{
|
||||
"CommandStats", Current.Stats.CommandStats
|
||||
},
|
||||
{
|
||||
"DeviceStats", Current.Stats.DeviceStats
|
||||
},
|
||||
{
|
||||
"FilesystemStats", Current.Stats.FilesystemStats
|
||||
},
|
||||
{
|
||||
"FilterStats", Current.Stats.FilterStats
|
||||
},
|
||||
{
|
||||
"MediaImageStats", Current.Stats.MediaImageStats
|
||||
},
|
||||
{
|
||||
"MediaScanStats", Current.Stats.MediaScanStats
|
||||
},
|
||||
{
|
||||
"PartitionStats", Current.Stats.PartitionStats
|
||||
},
|
||||
{
|
||||
"MediaStats", Current.Stats.MediaStats
|
||||
},
|
||||
{
|
||||
"VerifyStats", Current.Stats.VerifyStats
|
||||
}
|
||||
};
|
||||
|
||||
root.Add("Stats", stats);
|
||||
}
|
||||
|
||||
string preferencesPath =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library",
|
||||
"Preferences");
|
||||
|
||||
string preferencesFilePath = Path.Combine(preferencesPath, "com.claunia.discimagechef.plist");
|
||||
|
||||
FileStream fs = new FileStream(preferencesFilePath, FileMode.Create);
|
||||
var fs = new FileStream(preferencesFilePath, FileMode.Create);
|
||||
BinaryPropertyListWriter.Write(fs, root);
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
break;
|
||||
#if !NETSTANDARD2_0
|
||||
#if !NETSTANDARD2_0
|
||||
|
||||
// In case of Windows settings will be saved in the registry: HKLM/SOFTWARE/Claunia.com/DiscImageChef
|
||||
case PlatformID.Win32NT:
|
||||
case PlatformID.Win32S:
|
||||
@@ -489,64 +509,69 @@ namespace DiscImageChef.Settings
|
||||
{
|
||||
RegistryKey parentKey =
|
||||
Registry.CurrentUser.OpenSubKey("SOFTWARE", true)?.CreateSubKey("Claunia.com");
|
||||
|
||||
RegistryKey key = parentKey?.CreateSubKey("DiscImageChef");
|
||||
|
||||
if(key != null)
|
||||
{
|
||||
key.SetValue("SaveReportsGlobally", Current.SaveReportsGlobally);
|
||||
key.SetValue("ShareReports", Current.ShareReports);
|
||||
key.SetValue("GdprCompliance", Current.GdprCompliance);
|
||||
key.SetValue("ShareReports", Current.ShareReports);
|
||||
key.SetValue("GdprCompliance", Current.GdprCompliance);
|
||||
|
||||
if(Current.Stats != null)
|
||||
{
|
||||
key.SetValue("Statistics", true);
|
||||
key.SetValue("ShareStats", Current.Stats.ShareStats);
|
||||
key.SetValue("BenchmarkStats", Current.Stats.BenchmarkStats);
|
||||
key.SetValue("CommandStats", Current.Stats.CommandStats);
|
||||
key.SetValue("DeviceStats", Current.Stats.DeviceStats);
|
||||
key.SetValue("Statistics", true);
|
||||
key.SetValue("ShareStats", Current.Stats.ShareStats);
|
||||
key.SetValue("CommandStats", Current.Stats.CommandStats);
|
||||
key.SetValue("DeviceStats", Current.Stats.DeviceStats);
|
||||
key.SetValue("FilesystemStats", Current.Stats.FilesystemStats);
|
||||
key.SetValue("FilterStats", Current.Stats.FilterStats);
|
||||
key.SetValue("FilterStats", Current.Stats.FilterStats);
|
||||
key.SetValue("MediaImageStats", Current.Stats.MediaImageStats);
|
||||
key.SetValue("MediaScanStats", Current.Stats.MediaScanStats);
|
||||
key.SetValue("PartitionStats", Current.Stats.PartitionStats);
|
||||
key.SetValue("MediaStats", Current.Stats.MediaStats);
|
||||
key.SetValue("VerifyStats", Current.Stats.VerifyStats);
|
||||
key.SetValue("MediaScanStats", Current.Stats.MediaScanStats);
|
||||
key.SetValue("PartitionStats", Current.Stats.PartitionStats);
|
||||
key.SetValue("MediaStats", Current.Stats.MediaStats);
|
||||
key.SetValue("VerifyStats", Current.Stats.VerifyStats);
|
||||
}
|
||||
else
|
||||
{
|
||||
key.SetValue("Statistics", true);
|
||||
key.DeleteValue("ShareStats", false);
|
||||
key.DeleteValue("BenchmarkStats", false);
|
||||
key.DeleteValue("CommandStats", false);
|
||||
key.DeleteValue("DeviceStats", false);
|
||||
key.DeleteValue("ShareStats", false);
|
||||
key.DeleteValue("CommandStats", false);
|
||||
key.DeleteValue("DeviceStats", false);
|
||||
key.DeleteValue("FilesystemStats", false);
|
||||
key.DeleteValue("MediaImageStats", false);
|
||||
key.DeleteValue("MediaScanStats", false);
|
||||
key.DeleteValue("PartitionStats", false);
|
||||
key.DeleteValue("MediaStats", false);
|
||||
key.DeleteValue("VerifyStats", false);
|
||||
key.DeleteValue("MediaScanStats", false);
|
||||
key.DeleteValue("PartitionStats", false);
|
||||
key.DeleteValue("MediaStats", false);
|
||||
key.DeleteValue("VerifyStats", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Otherwise, settings will be saved in ~/.config/DiscImageChef.xml
|
||||
default:
|
||||
{
|
||||
string homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
|
||||
string xdgConfigPath =
|
||||
Path.Combine(homePath,
|
||||
Environment.GetEnvironmentVariable(XDG_CONFIG_HOME) ??
|
||||
XDG_CONFIG_HOME_RESOLVED);
|
||||
|
||||
string settingsPath = Path.Combine(xdgConfigPath, "DiscImageChef.xml");
|
||||
|
||||
if(!Directory.Exists(xdgConfigPath)) Directory.CreateDirectory(xdgConfigPath);
|
||||
if(!Directory.Exists(xdgConfigPath))
|
||||
Directory.CreateDirectory(xdgConfigPath);
|
||||
|
||||
FileStream fs = new FileStream(settingsPath, FileMode.Create);
|
||||
XmlSerializer xs = new XmlSerializer(Current.GetType());
|
||||
var fs = new FileStream(settingsPath, FileMode.Create);
|
||||
var xs = new XmlSerializer(Current.GetType());
|
||||
xs.Serialize(fs, Current);
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -558,31 +583,15 @@ namespace DiscImageChef.Settings
|
||||
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets default settings as all statistics, share everything
|
||||
/// </summary>
|
||||
static void SetDefaultSettings()
|
||||
/// <summary>Sets default settings as all statistics, share everything</summary>
|
||||
static void SetDefaultSettings() => Current = new DicSettings
|
||||
{
|
||||
Current = new DicSettings
|
||||
SaveReportsGlobally = true, ShareReports = true, GdprCompliance = 0, Stats = new StatsSettings
|
||||
{
|
||||
SaveReportsGlobally = true,
|
||||
ShareReports = true,
|
||||
GdprCompliance = 0,
|
||||
Stats = new StatsSettings
|
||||
{
|
||||
BenchmarkStats = true,
|
||||
CommandStats = true,
|
||||
DeviceStats = true,
|
||||
FilesystemStats = true,
|
||||
MediaImageStats = true,
|
||||
MediaScanStats = true,
|
||||
FilterStats = true,
|
||||
MediaStats = true,
|
||||
PartitionStats = true,
|
||||
ShareStats = true,
|
||||
VerifyStats = true
|
||||
}
|
||||
};
|
||||
}
|
||||
CommandStats = true, DeviceStats = true, FilesystemStats = true, MediaImageStats = true,
|
||||
MediaScanStats = true, FilterStats = true, MediaStats = true, PartitionStats = true,
|
||||
ShareStats = true, VerifyStats = true
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Benchmark.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Verbs.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Implements the 'benchmark' verb.
|
||||
//
|
||||
// --[ 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/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2020 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.CommandLine;
|
||||
using System.CommandLine.Invocation;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Core;
|
||||
|
||||
namespace DiscImageChef.Commands
|
||||
{
|
||||
internal class BenchmarkCommand : Command
|
||||
{
|
||||
public BenchmarkCommand() : base("benchmark", "Benchmarks hashing and entropy calculation.")
|
||||
{
|
||||
Add(new Option(new[]
|
||||
{
|
||||
"--block-size", "-b"
|
||||
}, "Block size.")
|
||||
{
|
||||
Argument = new Argument<int>(() => 512), Required = false
|
||||
});
|
||||
|
||||
Add(new Option(new[]
|
||||
{
|
||||
"--buffer-size", "-s"
|
||||
}, "Buffer size in mebibytes.")
|
||||
{
|
||||
Argument = new Argument<int>(() => 128), Required = false
|
||||
});
|
||||
|
||||
AddArgument(new Argument<string>
|
||||
{
|
||||
Arity = ArgumentArity.ExactlyOne, Description = "Disc image path", Name = "image-path"
|
||||
});
|
||||
|
||||
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
|
||||
}
|
||||
|
||||
public static int Invoke(bool debug, bool verbose, int blockSize, int bufferSize)
|
||||
{
|
||||
MainClass.PrintCopyright();
|
||||
|
||||
if(debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
|
||||
if(verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
Statistics.AddCommand("benchmark");
|
||||
|
||||
DicConsole.DebugWriteLine("Benchmark command", "--debug={0}", debug);
|
||||
DicConsole.DebugWriteLine("Benchmark command", "--verbose={0}", verbose);
|
||||
|
||||
Benchmark.InitProgressEvent += Progress.InitProgress;
|
||||
Benchmark.UpdateProgressEvent += Progress.UpdateProgress;
|
||||
Benchmark.EndProgressEvent += Progress.EndProgress;
|
||||
|
||||
BenchmarkResults results = Benchmark.Do(bufferSize * 1024 * 1024, blockSize);
|
||||
|
||||
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);
|
||||
|
||||
foreach(KeyValuePair<string, BenchmarkEntry> entry in results.Entries)
|
||||
DicConsole.WriteLine("Took {0} seconds to {1} buffer, {2:F3} MiB/sec.", entry.Value.TimeSpan, entry.Key,
|
||||
entry.Value.Speed);
|
||||
|
||||
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:F3} MiB/sec.",
|
||||
results.SeparateTime, results.SeparateSpeed);
|
||||
|
||||
DicConsole.WriteLine();
|
||||
DicConsole.WriteLine("Max memory used is {0} bytes", results.MaxMemory);
|
||||
DicConsole.WriteLine("Min memory used is {0} bytes", results.MinMemory);
|
||||
|
||||
return(int)ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,18 +165,6 @@ namespace DiscImageChef.Commands
|
||||
|
||||
pressedKey = new ConsoleKeyInfo();
|
||||
|
||||
while(pressedKey.Key != ConsoleKey.Y &&
|
||||
pressedKey.Key != ConsoleKey.N)
|
||||
{
|
||||
DicConsole.Write("Do you want to gather statistics about benchmarks? (Y/N): ");
|
||||
pressedKey = System.Console.ReadKey();
|
||||
DicConsole.WriteLine();
|
||||
}
|
||||
|
||||
Settings.Settings.Current.Stats.BenchmarkStats = pressedKey.Key == ConsoleKey.Y;
|
||||
|
||||
pressedKey = new ConsoleKeyInfo();
|
||||
|
||||
while(pressedKey.Key != ConsoleKey.Y &&
|
||||
pressedKey.Key != ConsoleKey.N)
|
||||
{
|
||||
|
||||
@@ -83,9 +83,6 @@
|
||||
<Compile Include="Commands\Media\MediaScan.cs" />
|
||||
<Compile Include="Commands\Remote.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="Commands\Benchmark.cs">
|
||||
<Gettext-ScanForTranslations>False</Gettext-ScanForTranslations>
|
||||
</Compile>
|
||||
<Compile Include="Commands\Configure.cs" />
|
||||
<Compile Include="Progress.cs" />
|
||||
<Compile Include="Commands\ListEncodings.cs" />
|
||||
|
||||
@@ -148,7 +148,6 @@ namespace DiscImageChef
|
||||
rootCommand.AddCommand(new ImageFamily());
|
||||
rootCommand.AddCommand(new MediaFamily());
|
||||
|
||||
rootCommand.AddCommand(new BenchmarkCommand());
|
||||
rootCommand.AddCommand(new ConfigureCommand(false, false));
|
||||
rootCommand.AddCommand(new FormatsCommand());
|
||||
rootCommand.AddCommand(new ListEncodingsCommand());
|
||||
|
||||
Reference in New Issue
Block a user