Files
Aaru/Metadata/Statistics.cs

390 lines
14 KiB
C#
Raw Normal View History

// /***************************************************************************
2020-02-27 12:31:21 +00:00
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Statistics.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : XML metadata.
//
// --[ Description ] ----------------------------------------------------------
//
// Define XML for statistics.
//
// --[ License ] --------------------------------------------------------------
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// ----------------------------------------------------------------------------
2020-12-31 23:08:21 +00:00
// Copyright © 2011-2021 Natalia Portillo
// ****************************************************************************/
using System.Collections.Generic;
2020-07-20 21:11:20 +01:00
using System.Diagnostics.CodeAnalysis;
using System.Xml.Serialization;
2021-08-17 13:55:59 +01:00
// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable UnusedMember.Global
2020-02-27 00:33:15 +00:00
namespace Aaru.CommonTypes.Metadata
{
2021-08-17 13:55:59 +01:00
/// <summary>
/// Statistics
/// </summary>
[XmlRoot("DicStats", Namespace = "", IsNullable = false)]
public class Stats
{
2021-08-17 13:55:59 +01:00
/// <summary>Executed commands</summary>
public CommandsStats Commands;
2021-08-17 13:55:59 +01:00
/// <summary>Operating systems Aaru has run from</summary>
[XmlArrayItem("OperatingSystem")]
public List<OsStats> OperatingSystems { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Aaru versions</summary>
[XmlArrayItem("Version")]
public List<NameValueStats> Versions { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Detected filesystems</summary>
[XmlArrayItem("Filesystem")]
public List<NameValueStats> Filesystems { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Detected partitioning schemes</summary>
[XmlArrayItem("Scheme")]
public List<NameValueStats> Partitions { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Media image formats</summary>
[XmlArrayItem("Format")]
public List<NameValueStats> MediaImages { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Used filters</summary>
[XmlArrayItem("Filter", IsNullable = true)]
public List<NameValueStats> Filters { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Found devices</summary>
[XmlArrayItem("Device", IsNullable = true)]
public List<DeviceStats> Devices { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Found media types, real, and in image</summary>
[XmlArrayItem("Media")]
public List<MediaStats> Medias { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Benchmark statistics</summary>
public BenchmarkStats Benchmark { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Media scanning statistics</summary>
public MediaScanStats MediaScan { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Image verification statistics</summary>
public VerifyStats Verify { get; set; }
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// DTO for statistics
/// </summary>
[SuppressMessage("ReSharper", "CollectionNeverQueried.Global")]
2018-12-21 18:17:49 +00:00
public class StatsDto
{
2021-08-17 13:55:59 +01:00
/// <summary>Executed commands</summary>
2019-12-04 18:35:20 +00:00
public List<NameValueStats> Commands { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Operating systems Aaru has run from</summary>
2019-12-04 18:35:20 +00:00
public List<OsStats> OperatingSystems { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Aaru versions</summary>
2019-12-04 18:35:20 +00:00
public List<NameValueStats> Versions { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Detected filesystems</summary>
2019-12-04 18:35:20 +00:00
public List<NameValueStats> Filesystems { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Detected partitioning schemes</summary>
2019-12-04 18:35:20 +00:00
public List<NameValueStats> Partitions { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Media image formats</summary>
2019-12-04 18:35:20 +00:00
public List<NameValueStats> MediaFormats { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Used filters</summary>
2019-12-04 18:35:20 +00:00
public List<NameValueStats> Filters { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Found devices</summary>
2019-12-04 18:35:20 +00:00
public List<DeviceStats> Devices { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Found media types, real, and in image</summary>
2019-12-04 18:35:20 +00:00
public List<MediaStats> Medias { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Remote applications</summary>
2019-12-04 18:35:20 +00:00
public List<OsStats> RemoteApplications { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Remote application architectures</summary>
2019-12-04 18:35:20 +00:00
public List<NameValueStats> RemoteArchitectures { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>Operating systems where a remote application has been running</summary>
2019-12-04 18:35:20 +00:00
public List<OsStats> RemoteOperatingSystems { get; set; }
2018-12-21 18:17:49 +00:00
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// Command execution statistics
/// </summary>
[SuppressMessage("ReSharper", "UnassignedField.Global")]
public class CommandsStats
{
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the filesystem info command has been used</summary>
public long Analyze;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the benchmark command has been used</summary>
public long Benchmark;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the image checksum command has been used</summary>
public long Checksum;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the image compare command has been used</summary>
public long Compare;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the image convert command has been used</summary>
public long ConvertImage;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the image create-sidecar command has been used</summary>
public long CreateSidecar;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the image decode command has been used</summary>
public long Decode;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the device info command has been used</summary>
public long DeviceInfo;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the device report command has been used</summary>
public long DeviceReport;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the media dump command has been used</summary>
public long DumpMedia;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the image entropy command has been used</summary>
public long Entropy;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the filesystem extract command has been used</summary>
public long ExtractFiles;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the list formats command has been used</summary>
public long Formats;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the image info command has been used</summary>
public long ImageInfo;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the device list command has been used</summary>
public long ListDevices;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the list encodings command has been used</summary>
public long ListEncodings;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the filesystem ls command has been used</summary>
public long Ls;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the media info command has been used</summary>
public long MediaInfo;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the media scan command has been used</summary>
public long MediaScan;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the image printhex command has been used</summary>
public long PrintHex;
2021-08-17 13:55:59 +01:00
/// <summary>Number of times the image verify command has been used</summary>
public long Verify;
}
2021-08-17 13:55:59 +01:00
/// <summary>Statistics of verified media</summary>
public class VerifiedItems
{
2021-08-17 13:55:59 +01:00
/// <summary>Number of correct images</summary>
public long Correct;
2021-08-17 13:55:59 +01:00
/// <summary>Number of failed images</summary>
public long Failed;
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// Verification statistics
/// </summary>
public class VerifyStats
{
2021-08-17 13:55:59 +01:00
/// <summary>
/// Image verification statistics
/// </summary>
public VerifiedItems MediaImages;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Image contents verification statistics
/// </summary>
public ScannedSectors Sectors;
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// Image contents verification statistics
/// </summary>
public class ScannedSectors
{
2021-08-17 13:55:59 +01:00
/// <summary>
/// Sectors found to be correct
/// </summary>
public long Correct;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Sectors found to be incorrect
/// </summary>
public long Error;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Total number of verified sectors
/// </summary>
public long Total;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Total number of sectors that could not be verified
/// </summary>
public long Unverifiable;
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// Media scanning time statistics
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class TimeStats
{
2021-08-17 13:55:59 +01:00
/// <summary>Number of sectors that took more than 3ms but less than 100ms to read</summary>
public long LessThan10ms;
2021-08-17 13:55:59 +01:00
/// <summary>Number of sectors that took more than 50ms but less than 150ms to read</summary>
public long LessThan150ms;
2021-08-17 13:55:59 +01:00
/// <summary>Number of sectors that took less than 3ms to read</summary>
public long LessThan3ms;
2021-08-17 13:55:59 +01:00
/// <summary>Number of sectors that took more than 150ms but less than 500ms to read</summary>
public long LessThan500ms;
2021-08-17 13:55:59 +01:00
/// <summary>Number of sectors that took more than 10ms but less than 50ms to read</summary>
public long LessThan50ms;
2021-08-17 13:55:59 +01:00
/// <summary>Number of sectors that took more than 500ms to read</summary>
public long MoreThan500ms;
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// Media scanning statistics
/// </summary>
public class MediaScanStats
{
2021-08-17 13:55:59 +01:00
/// <summary>
/// Statistics of scanned sectors
/// </summary>
public ScannedSectors Sectors;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Scan time statistics
/// </summary>
public TimeStats Times;
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// Checksum type statistics
/// </summary>
public class ChecksumStats
{
2021-08-17 13:55:59 +01:00
/// <summary>
/// Checksum algorithm
/// </summary>
2019-03-11 19:22:26 +00:00
[XmlAttribute]
public string algorithm;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Time taken to execute algorithm
/// </summary>
2019-03-11 19:22:26 +00:00
[XmlText]
public double Value;
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// Benchmark statistics
/// </summary>
public class BenchmarkStats
{
2021-08-17 13:55:59 +01:00
/// <summary>
/// Total time taken to run the checksum algorithms in parallel
/// </summary>
2019-03-11 19:22:26 +00:00
public double All;
2021-08-17 13:55:59 +01:00
/// <summary>
/// List of time taken by each checksum algorithm
/// </summary>
2019-03-11 19:22:26 +00:00
[XmlElement("Checksum")]
public List<ChecksumStats> Checksum;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Time taken to benchmark entropy calculation
/// </summary>
2019-03-11 19:22:26 +00:00
public double Entropy;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Maximum amount of memory used while running the benchmark
/// </summary>
2019-03-11 19:22:26 +00:00
public long MaxMemory;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Minimum amount of memory used while running the benchmark
/// </summary>
2019-03-11 19:22:26 +00:00
public long MinMemory;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Total time taken to run the checksum algorithms sequentially
/// </summary>
2019-03-11 19:22:26 +00:00
public double Sequential;
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// Media statistics
/// </summary>
public class MediaStats
{
2021-08-17 13:55:59 +01:00
/// <summary>
/// Found in a real device?
/// </summary>
2019-03-11 19:22:26 +00:00
[XmlAttribute]
public bool real;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Media type
/// </summary>
2019-03-11 19:22:26 +00:00
[XmlAttribute]
public string type;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Number of times it has been found
/// </summary>
2019-03-11 19:22:26 +00:00
[XmlText]
public long Value;
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// Device statistics
/// </summary>
public class DeviceStats
{
2021-08-17 13:55:59 +01:00
/// <summary>
/// Is manufacturer null?
/// </summary>
2019-03-11 19:22:26 +00:00
[XmlIgnore]
public bool ManufacturerSpecified;
2021-08-17 13:55:59 +01:00
/// <summary>
/// Manufacturer string
/// </summary>
2019-03-11 19:22:26 +00:00
public string Manufacturer { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>
/// Model string
/// </summary>
2019-03-11 19:22:26 +00:00
public string Model { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>
/// Revision or firmware version
/// </summary>
2019-03-11 19:22:26 +00:00
public string Revision { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>
/// Bus the device was attached to
/// </summary>
2019-03-11 19:22:26 +00:00
public string Bus { get; set; }
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// Name=value pair statistics
/// </summary>
2020-07-20 21:11:20 +01:00
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class NameValueStats
{
2021-08-17 13:55:59 +01:00
/// <summary>
/// Name
/// </summary>
[XmlAttribute]
public string name { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>
/// Number of times it has been used/found
/// </summary>
[XmlText]
public long Value { get; set; }
}
2021-08-17 13:55:59 +01:00
/// <summary>
/// Operating system statistics
/// </summary>
2020-07-20 21:11:20 +01:00
[SuppressMessage("ReSharper", "InconsistentNaming")]
public class OsStats
{
2021-08-17 13:55:59 +01:00
/// <summary>
/// Operating system name
/// </summary>
[XmlAttribute]
public string name { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>
/// Operating system version
/// </summary>
[XmlAttribute]
public string version { get; set; }
2021-08-17 13:55:59 +01:00
/// <summary>
/// Number of times Aaru run on it
/// </summary>
[XmlText]
public long Value { get; set; }
}
}