Use a more precise mechanism to measure elapsed times in operations.

This commit is contained in:
2023-09-26 20:16:24 +01:00
parent 8786474169
commit 09a5c00891
38 changed files with 692 additions and 597 deletions

View File

@@ -96,17 +96,14 @@ public partial class Dump
if(ataIdNullable != null) if(ataIdNullable != null)
{ {
Identify.IdentifyDevice ataId = ataIdNullable.Value; Identify.IdentifyDevice ataId = ataIdNullable.Value;
byte[] ataIdentify = cmdBuf; byte[] ataIdentify = cmdBuf;
double totalDuration = 0;
double currentSpeed = 0;
double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue;
cmdBuf = Array.Empty<byte>(); cmdBuf = Array.Empty<byte>();
DateTime start;
DateTime end;
double totalDuration = 0;
double currentSpeed = 0;
double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue;
// Initialize reader // Initialize reader
UpdateStatus?.Invoke(Localization.Core.Initializing_reader); UpdateStatus?.Invoke(Localization.Core.Initializing_reader);
_dumpLog.WriteLine(Localization.Core.Initializing_reader); _dumpLog.WriteLine(Localization.Core.Initializing_reader);
@@ -298,8 +295,8 @@ public partial class Dump
bool newTrim = false; bool newTrim = false;
start = DateTime.UtcNow; _dumpStopwatch.Restart();
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -331,13 +328,13 @@ public partial class Dump
bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration, out _, out _); bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration, out _, out _);
_writeStopwatch.Restart();
if(!error) if(!error)
{ {
mhddLog.Write(i, duration, blocksToRead); mhddLog.Write(i, duration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
DateTime writeStart = DateTime.Now;
outputFormat.WriteSectors(cmdBuf, i, blocksToRead); outputFormat.WriteSectors(cmdBuf, i, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true); extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead); _mediaGraph?.PaintSectorsGood(i, blocksToRead);
} }
@@ -352,38 +349,41 @@ public partial class Dump
mhddLog.Write(i, duration < 500 ? 65535 : duration, _skip); mhddLog.Write(i, duration < 500 ? 65535 : duration, _skip);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
DateTime writeStart = DateTime.Now;
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
_dumpLog.WriteLine(Localization.Core.Skipping_0_blocks_from_errored_block_1, _skip, i); _dumpLog.WriteLine(Localization.Core.Skipping_0_blocks_from_errored_block_1, _skip, i);
i += _skip - blocksToRead; i += _skip - blocksToRead;
newTrim = true; newTrim = true;
} }
_writeStopwatch.Stop();
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
_resume.NextBlock = i + blocksToRead; _resume.NextBlock = i + blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_speedStopwatch.Stop();
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
end = DateTime.Now; _dumpStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -394,7 +394,7 @@ public partial class Dump
Per(imageWriteDuration.Seconds()))); Per(imageWriteDuration.Seconds())));
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(Localization.Core.Average_dump_speed_0, _dumpLog.WriteLine(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()). ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()).
@@ -410,7 +410,7 @@ public partial class Dump
_trim && _trim &&
newTrim) newTrim)
{ {
start = DateTime.UtcNow; _trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors); UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
_dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors); _dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors);
@@ -445,13 +445,13 @@ public partial class Dump
} }
EndProgress?.Invoke(); EndProgress?.Invoke();
end = DateTime.UtcNow; _trimStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
} }
#endregion Trimming #endregion Trimming
@@ -563,8 +563,8 @@ public partial class Dump
ulong currentBlock = 0; ulong currentBlock = 0;
blocks = (ulong)(cylinders * heads * sectors); blocks = (ulong)(cylinders * heads * sectors);
start = DateTime.UtcNow; _dumpStopwatch.Restart();
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -602,16 +602,17 @@ public partial class Dump
totalDuration += duration; totalDuration += duration;
_writeStopwatch.Restart();
if(!error || recoveredError) if(!error || recoveredError)
{ {
mhddLog.Write(currentBlock, duration); mhddLog.Write(currentBlock, duration);
ibgLog.Write(currentBlock, currentSpeed * 1024); ibgLog.Write(currentBlock, currentSpeed * 1024);
DateTime writeStart = DateTime.Now;
outputFormat.WriteSector(cmdBuf, outputFormat.WriteSector(cmdBuf,
(ulong)((((cy * heads) + hd) * sectors) + (sc - 1))); (ulong)((((cy * heads) + hd) * sectors) + (sc - 1)));
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(currentBlock); extents.Add(currentBlock);
_mediaGraph?.PaintSectorGood((ulong)((((cy * heads) + hd) * sectors) + (sc - 1))); _mediaGraph?.PaintSectorGood((ulong)((((cy * heads) + hd) * sectors) + (sc - 1)));
@@ -624,40 +625,42 @@ public partial class Dump
mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration); mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration);
ibgLog.Write(currentBlock, 0); ibgLog.Write(currentBlock, 0);
DateTime writeStart = DateTime.Now;
outputFormat.WriteSector(new byte[blockSize], outputFormat.WriteSector(new byte[blockSize],
(ulong)((((cy * heads) + hd) * sectors) + (sc - 1))); (ulong)((((cy * heads) + hd) * sectors) + (sc - 1)));
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
} }
_writeStopwatch.Stop();
sectorSpeedStart++; sectorSpeedStart++;
currentBlock++; currentBlock++;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
} }
} }
_speedStopwatch.Stop();
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
end = DateTime.Now; _dumpStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -668,7 +671,7 @@ public partial class Dump
Per(imageWriteDuration.Seconds()))); Per(imageWriteDuration.Seconds())));
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(Localization.Core.Average_dump_speed_0, _dumpLog.WriteLine(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()). ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()).
@@ -700,15 +703,15 @@ public partial class Dump
_dumpLog.WriteLine(Localization.Core.Closing_output_file); _dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
DateTime closeStart = DateTime.Now; _imageCloseStopwatch.Restart();
outputFormat.Close(); outputFormat.Close();
DateTime closeEnd = DateTime.Now; _imageCloseStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(Localization.Core.Closed_in_0, _dumpLog.WriteLine(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
if(_aborted) if(_aborted)
{ {
@@ -747,7 +750,7 @@ public partial class Dump
return; return;
} }
DateTime chkStart = DateTime.UtcNow; _sidecarStopwatch.Restart();
_sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding); _sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding);
@@ -856,19 +859,20 @@ public partial class Dump
} }
}; };
DateTime chkEnd = DateTime.UtcNow; _sidecarStopwatch.Stop();
totalChkDuration = (chkEnd - chkStart).TotalMilliseconds; totalChkDuration = _sidecarStopwatch.Elapsed.TotalMilliseconds;
UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0,
(chkEnd - chkStart).Humanize(minUnit: TimeUnit.Second))); _sidecarStopwatch.Elapsed.
Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()))); Per(totalChkDuration.Milliseconds())));
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0,
(chkEnd - chkStart).Humanize(minUnit: TimeUnit.Second)); _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -938,11 +942,11 @@ public partial class Dump
UpdateStatus?. UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second), _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).

View File

@@ -157,7 +157,6 @@ partial class Dump
Dictionary<byte, int> smallestPregapLbaPerTrack) Dictionary<byte, int> smallestPregapLbaPerTrack)
{ {
ulong sectorSpeedStart = 0; // Used to calculate correct speed ulong sectorSpeedStart = 0; // Used to calculate correct speed
DateTime timeSpeedStart = DateTime.UtcNow; // Time of start for speed calculation
bool sense; // Sense indicator bool sense; // Sense indicator
byte[] cmdBuf; // Data buffer byte[] cmdBuf; // Data buffer
byte[] senseBuf; // Sense buffer byte[] senseBuf; // Sense buffer
@@ -247,7 +246,7 @@ partial class Dump
mhddLog.Write(i + r, cmdDuration); mhddLog.Write(i + r, cmdDuration);
ibgLog.Write(i + r, currentSpeed * 1024); ibgLog.Write(i + r, currentSpeed * 1024);
extents.Add(i + r, 1, true); extents.Add(i + r, 1, true);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
if(cdiReadyReadAsAudio) if(cdiReadyReadAsAudio)
FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel,
@@ -285,7 +284,7 @@ partial class Dump
else else
outputOptical.WriteSectorsLong(cmdBuf, i + r, 1); outputOptical.WriteSectorsLong(cmdBuf, i + r, 1);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
_mediaGraph?.PaintSectorGood(i + r); _mediaGraph?.PaintSectorGood(i + r);
} }
@@ -305,20 +304,23 @@ partial class Dump
break; break;
} }
_writeStopwatch.Stop();
sectorSpeedStart += r; sectorSpeedStart += r;
_resume.NextBlock = i + r; _resume.NextBlock = i + r;
elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_speedStopwatch.Restart();
if(!sense && if(!sense &&
!_dev.Error) !_dev.Error)
{ {
@@ -329,7 +331,7 @@ partial class Dump
mhddLog.Write(i, cmdDuration); mhddLog.Write(i, cmdDuration);
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
extents.Add(i, blocksToRead, true); extents.Add(i, blocksToRead, true);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
if(supportedSubchannel != MmcSubchannel.None) if(supportedSubchannel != MmcSubchannel.None)
{ {
@@ -398,7 +400,7 @@ partial class Dump
outputOptical.WriteSectorsLong(cmdBuf, i, blocksToRead); outputOptical.WriteSectorsLong(cmdBuf, i, blocksToRead);
} }
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
_mediaGraph?.PaintSectorsGood(i, blocksToRead); _mediaGraph?.PaintSectorsGood(i, blocksToRead);
} }
@@ -411,20 +413,22 @@ partial class Dump
break; break;
} }
_writeStopwatch.Stop();
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
_resume.NextBlock = i + blocksToRead; _resume.NextBlock = i + blocksToRead;
elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_speedStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
} }
} }

View File

@@ -101,7 +101,6 @@ partial class Dump
Dictionary<byte, int> smallestPregapLbaPerTrack) Dictionary<byte, int> smallestPregapLbaPerTrack)
{ {
ulong sectorSpeedStart = 0; // Used to calculate correct speed ulong sectorSpeedStart = 0; // Used to calculate correct speed
DateTime timeSpeedStart = DateTime.UtcNow; // Time of start for speed calculation
uint blocksToRead; // How many sectors to read at once uint blocksToRead; // How many sectors to read at once
bool sense = true; // Sense indicator bool sense = true; // Sense indicator
byte[] cmdBuf = null; // Data buffer byte[] cmdBuf = null; // Data buffer
@@ -129,6 +128,8 @@ partial class Dump
for(ulong i = _resume.NextBlock; (long)i <= lastSector; i += blocksToRead) for(ulong i = _resume.NextBlock; (long)i <= lastSector; i += blocksToRead)
{ {
_speedStopwatch.Restart();
if(_aborted) if(_aborted)
{ {
currentTry.Extents = ExtentsConverter.ToMetadata(extents); currentTry.Extents = ExtentsConverter.ToMetadata(extents);
@@ -422,6 +423,8 @@ partial class Dump
!nextData && !nextData &&
sense) sense)
{ {
_speedStopwatch.Restart();
for(uint r = 0; r < blocksToRead; r++) for(uint r = 0; r < blocksToRead; r++)
{ {
UpdateProgress?. UpdateProgress?.
@@ -481,7 +484,7 @@ partial class Dump
mhddLog.Write(i + r, cmdDuration); mhddLog.Write(i + r, cmdDuration);
ibgLog.Write(i + r, currentSpeed * 1024); ibgLog.Write(i + r, currentSpeed * 1024);
extents.Add(i + r, 1, true); extents.Add(i + r, 1, true);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
if(supportedSubchannel != MmcSubchannel.None) if(supportedSubchannel != MmcSubchannel.None)
{ {
@@ -559,14 +562,14 @@ partial class Dump
_mediaGraph?.PaintSectorGood(i + r); _mediaGraph?.PaintSectorGood(i + r);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
} }
else else
{ {
_errorLog?.WriteLine(i + r, _dev.Error, _dev.LastError, senseBuf); _errorLog?.WriteLine(i + r, _dev.Error, _dev.LastError, senseBuf);
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
if(supportedSubchannel != MmcSubchannel.None) if(supportedSubchannel != MmcSubchannel.None)
{ {
@@ -589,7 +592,7 @@ partial class Dump
} }
} }
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
_mediaGraph?.PaintSectorBad(i + r); _mediaGraph?.PaintSectorBad(i + r);
@@ -605,18 +608,20 @@ partial class Dump
newTrim = true; newTrim = true;
} }
_writeStopwatch.Stop();
sectorSpeedStart += r; sectorSpeedStart += r;
_resume.NextBlock = i + r; _resume.NextBlock = i + r;
elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
continue; continue;
@@ -641,7 +646,7 @@ partial class Dump
mhddLog.Write(i, cmdDuration, blocksToRead); mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
extents.Add(i, blocksToRead, true); extents.Add(i, blocksToRead, true);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
if(supportedSubchannel != MmcSubchannel.None) if(supportedSubchannel != MmcSubchannel.None)
{ {
@@ -722,7 +727,7 @@ partial class Dump
_mediaGraph?.PaintSectorsGood(i, blocksToRead); _mediaGraph?.PaintSectorsGood(i, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
} }
else else
{ {
@@ -747,7 +752,7 @@ partial class Dump
_skip = (uint)(blocks - i); _skip = (uint)(blocks - i);
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
if(supportedSubchannel != MmcSubchannel.None) if(supportedSubchannel != MmcSubchannel.None)
{ {
@@ -770,7 +775,7 @@ partial class Dump
} }
} }
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) for(ulong b = i; b < i + _skip; b++)
_resume.BadBlocks.Add(b); _resume.BadBlocks.Add(b);
@@ -784,20 +789,23 @@ partial class Dump
newTrim = true; newTrim = true;
} }
_writeStopwatch.Stop();
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
_resume.NextBlock = i + blocksToRead; _resume.NextBlock = i + blocksToRead;
elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_speedStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();

View File

@@ -75,9 +75,7 @@ sealed partial class Dump
DumpHardware currentTry = null; // Current dump hardware try DumpHardware currentTry = null; // Current dump hardware try
double currentSpeed = 0; // Current read speed double currentSpeed = 0; // Current read speed
int? discOffset = null; // Disc write offset int? discOffset = null; // Disc write offset
DateTime dumpStart = DateTime.UtcNow; // Time of dump start ExtentsULong extents = null; // Extents
DateTime end; // Time of operation end
ExtentsULong extents = null; // Extents
bool hiddenData; // Hidden track is data bool hiddenData; // Hidden track is data
IbgLog ibgLog; // IMGBurn log IbgLog ibgLog; // IMGBurn log
double imageWriteDuration = 0; // Duration of image write double imageWriteDuration = 0; // Duration of image write
@@ -99,7 +97,6 @@ sealed partial class Dump
int sectorsForOffset = 0; // Sectors needed to fix offset int sectorsForOffset = 0; // Sectors needed to fix offset
bool sense = true; // Sense indicator bool sense = true; // Sense indicator
int sessions; // Number of sessions in disc int sessions; // Number of sessions in disc
DateTime start; // Start of operation
SubchannelLog subLog = null; // Subchannel log SubchannelLog subLog = null; // Subchannel log
uint subSize = 0; // Subchannel size in bytes uint subSize = 0; // Subchannel size in bytes
TrackSubchannelType subType = TrackSubchannelType.None; // Track subchannel type TrackSubchannelType subType = TrackSubchannelType.None; // Track subchannel type
@@ -1167,7 +1164,7 @@ sealed partial class Dump
} }
// Start reading // Start reading
start = DateTime.UtcNow; _dumpStopwatch.Restart();
if(dskType == MediaType.CDIREADY || cdiWithHiddenTrack1) if(dskType == MediaType.CDIREADY || cdiWithHiddenTrack1)
{ {
@@ -1289,14 +1286,14 @@ sealed partial class Dump
smallestPregapLbaPerTrack); smallestPregapLbaPerTrack);
*/ */
end = DateTime.UtcNow; _dumpStopwatch.Stop();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -1307,7 +1304,7 @@ sealed partial class Dump
Per(imageWriteDuration.Seconds()))); Per(imageWriteDuration.Seconds())));
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -1439,12 +1436,12 @@ sealed partial class Dump
_dumpLog.WriteLine(Localization.Core.Closing_output_file); _dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
DateTime closeStart = DateTime.Now; _imageCloseStopwatch.Restart();
outputOptical.Close(); outputOptical.Close();
DateTime closeEnd = DateTime.Now; _imageCloseStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
subLog?.Close(); subLog?.Close();
@@ -1461,16 +1458,16 @@ sealed partial class Dump
WriteOpticalSidecar(blockSize, blocks, dskType, null, mediaTags, sessions, out totalChkDuration, WriteOpticalSidecar(blockSize, blocks, dskType, null, mediaTags, sessions, out totalChkDuration,
discOffset); discOffset);
end = DateTime.UtcNow; _dumpStopwatch.Stop();
UpdateStatus?.Invoke(""); UpdateStatus?.Invoke("");
UpdateStatus?. UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second), _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).

View File

@@ -151,7 +151,7 @@ partial class Dump
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
extents.Add(i, _maximumReadable, true); extents.Add(i, _maximumReadable, true);
leadOutExtents.Remove(i); leadOutExtents.Remove(i);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
if(supportedSubchannel != MmcSubchannel.None) if(supportedSubchannel != MmcSubchannel.None)
{ {
@@ -184,7 +184,7 @@ partial class Dump
else else
outputOptical.WriteSectors(cmdBuf, i, _maximumReadable); outputOptical.WriteSectors(cmdBuf, i, _maximumReadable);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
} }
else else
{ {
@@ -195,7 +195,7 @@ partial class Dump
return; // TODO: Return more cleanly return; // TODO: Return more cleanly
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
if(supportedSubchannel != MmcSubchannel.None) if(supportedSubchannel != MmcSubchannel.None)
{ {
@@ -207,13 +207,14 @@ partial class Dump
else else
outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1); outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, _skip); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration, _skip);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
} }
_writeStopwatch.Stop();
double newSpeed = (double)blockSize * _maximumReadable / 1048576 / (cmdDuration / 1000); double newSpeed = (double)blockSize * _maximumReadable / 1048576 / (cmdDuration / 1000);
if(!double.IsInfinity(newSpeed)) if(!double.IsInfinity(newSpeed))
@@ -323,7 +324,7 @@ partial class Dump
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
extents.Add(i, _maximumReadable, true); extents.Add(i, _maximumReadable, true);
leadOutExtents.Remove(i); leadOutExtents.Remove(i);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
if(supportedSubchannel != MmcSubchannel.None) if(supportedSubchannel != MmcSubchannel.None)
{ {
@@ -356,7 +357,7 @@ partial class Dump
else else
outputOptical.WriteSectors(cmdBuf, i, _maximumReadable); outputOptical.WriteSectors(cmdBuf, i, _maximumReadable);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
} }
else else
{ {
@@ -367,7 +368,7 @@ partial class Dump
return; // TODO: Return more cleanly return; // TODO: Return more cleanly
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
if(supportedSubchannel != MmcSubchannel.None) if(supportedSubchannel != MmcSubchannel.None)
{ {
@@ -380,13 +381,14 @@ partial class Dump
else else
outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1); outputOptical.WriteSectors(new byte[blockSize * _skip], i, 1);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration); mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
} }
_writeStopwatch.Stop();
double newSpeed = (double)blockSize * _maximumReadable / 1048576 / (cmdDuration / 1000); double newSpeed = (double)blockSize * _maximumReadable / 1048576 / (cmdDuration / 1000);
if(!double.IsInfinity(newSpeed)) if(!double.IsInfinity(newSpeed))

View File

@@ -65,7 +65,6 @@ partial class Dump
bool sense; // Sense indicator bool sense; // Sense indicator
byte[] cmdBuf; // Data buffer byte[] cmdBuf; // Data buffer
double cmdDuration; // Command execution time double cmdDuration; // Command execution time
DateTime timeSpeedStart; // Time of start for speed calculation
ulong sectorSpeedStart = 0; // Used to calculate correct speed ulong sectorSpeedStart = 0; // Used to calculate correct speed
bool gotFirstTrackPregap = false; bool gotFirstTrackPregap = false;
int firstTrackPregapSectorsGood = 0; int firstTrackPregapSectorsGood = 0;
@@ -74,7 +73,7 @@ partial class Dump
_dumpLog.WriteLine(Localization.Core.Reading_first_track_pregap); _dumpLog.WriteLine(Localization.Core.Reading_first_track_pregap);
UpdateStatus?.Invoke(Localization.Core.Reading_first_track_pregap); UpdateStatus?.Invoke(Localization.Core.Reading_first_track_pregap);
InitProgress?.Invoke(); InitProgress?.Invoke();
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
for(int firstTrackPregapBlock = -150; firstTrackPregapBlock < 0 && _resume.NextBlock == 0; for(int firstTrackPregapBlock = -150; firstTrackPregapBlock < 0 && _resume.NextBlock == 0;
firstTrackPregapBlock++) firstTrackPregapBlock++)
@@ -115,16 +114,18 @@ partial class Dump
sectorSpeedStart++; sectorSpeedStart++;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_speedStopwatch.Stop();
if(firstTrackPregapSectorsGood > 0) if(firstTrackPregapSectorsGood > 0)
mediaTags.Add(MediaTagType.CD_FirstTrackPregap, firstTrackPregapMs.ToArray()); mediaTags.Add(MediaTagType.CD_FirstTrackPregap, firstTrackPregapMs.ToArray());

View File

@@ -83,8 +83,6 @@ partial class Dump
Dictionary<byte, string> isrcs, ref string mcn, HashSet<int> subchannelExtents, Dictionary<byte, string> isrcs, ref string mcn, HashSet<int> subchannelExtents,
Dictionary<byte, int> smallestPregapLbaPerTrack) Dictionary<byte, int> smallestPregapLbaPerTrack)
{ {
DateTime start;
DateTime end;
bool sense = true; // Sense indicator bool sense = true; // Sense indicator
byte[] cmdBuf = null; // Data buffer byte[] cmdBuf = null; // Data buffer
double cmdDuration = 0; // Command execution time double cmdDuration = 0; // Command execution time
@@ -107,10 +105,10 @@ partial class Dump
!newTrim) !newTrim)
return; return;
start = DateTime.UtcNow;
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors); UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
_dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors); _dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors);
InitProgress?.Invoke(); InitProgress?.Invoke();
_trimStopwatch.Restart();
trimStart: trimStart:
ulong[] tmpArray = _resume.BadBlocks.ToArray(); ulong[] tmpArray = _resume.BadBlocks.ToArray();
@@ -292,13 +290,13 @@ partial class Dump
outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector); outputOptical.WriteSector(Sector.GetUserData(cmdBuf), badSector);
} }
_trimStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
end = DateTime.UtcNow;
UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
} }
} }

View File

@@ -33,7 +33,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -115,6 +115,12 @@ public partial class Dump
bool _supportsPlextorD8; bool _supportsPlextorD8;
bool _useBufferedReads; bool _useBufferedReads;
static readonly TimeSpan _oneSecond = 1.Seconds(); static readonly TimeSpan _oneSecond = 1.Seconds();
readonly Stopwatch _dumpStopwatch;
readonly Stopwatch _sidecarStopwatch;
readonly Stopwatch _speedStopwatch;
readonly Stopwatch _trimStopwatch;
readonly Stopwatch _writeStopwatch;
readonly Stopwatch _imageCloseStopwatch;
/// <summary>Initializes dumpers</summary> /// <summary>Initializes dumpers</summary>
/// <param name="doResume">Should resume?</param> /// <param name="doResume">Should resume?</param>
@@ -207,6 +213,12 @@ public partial class Dump
_ignoreCdrRunOuts = ignoreCdrRunOuts; _ignoreCdrRunOuts = ignoreCdrRunOuts;
_createGraph = createGraph; _createGraph = createGraph;
_dimensions = dimensions; _dimensions = dimensions;
_dumpStopwatch = new Stopwatch();
_sidecarStopwatch = new Stopwatch();
_speedStopwatch = new Stopwatch();
_trimStopwatch = new Stopwatch();
_writeStopwatch = new Stopwatch();
_imageCloseStopwatch = new Stopwatch();
} }
/// <summary>Starts dumping with the established fields and autodetecting the device type</summary> /// <summary>Starts dumping with the established fields and autodetecting the device type</summary>

View File

@@ -292,10 +292,10 @@ public partial class Dump
if(_createGraph) if(_createGraph)
_mediaGraph = new BlockMap((int)_dimensions, (int)_dimensions, romSectors); _mediaGraph = new BlockMap((int)_dimensions, (int)_dimensions, romSectors);
DateTime start = DateTime.UtcNow; _dumpStopwatch.Restart();
double imageWriteDuration = 0; double imageWriteDuration = 0;
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -329,12 +329,13 @@ public partial class Dump
totalDuration += cmdDuration; totalDuration += cmdDuration;
_writeStopwatch.Restart();
if(!sense && if(!sense &&
!_dev.Error) !_dev.Error)
{ {
DateTime writeStart = DateTime.Now;
outputBai.WriteBytes(readBuffer, 0, readBuffer.Length, out _); outputBai.WriteBytes(readBuffer, 0, readBuffer.Length, out _);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
_mediaGraph.PaintSectorsGood(i, blocksToRead); _mediaGraph.PaintSectorsGood(i, blocksToRead);
} }
else else
@@ -349,18 +350,22 @@ public partial class Dump
i += _skip - blocksToRead; i += _skip - blocksToRead;
} }
_writeStopwatch.Stop();
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * 512 / (1048576 * elapsed); currentSpeed = sectorSpeedStart * 512 / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_speedStopwatch.Stop();
if(romRemaining > 0 && if(romRemaining > 0 &&
!_aborted) !_aborted)
{ {
@@ -384,9 +389,10 @@ public partial class Dump
if(!sense && if(!sense &&
!_dev.Error) !_dev.Error)
{ {
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputBai.WriteBytes(readBuffer, 0, (int)romRemaining, out _); outputBai.WriteBytes(readBuffer, 0, (int)romRemaining, out _);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
_writeStopwatch.Stop();
} }
else else
{ {
@@ -401,10 +407,10 @@ public partial class Dump
} }
} }
DateTime end = DateTime.UtcNow;
EndProgress?.Invoke(); EndProgress?.Invoke();
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, (end - start).Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(512 * (romSectors + 1)). ByteSize.FromBytes(512 * (romSectors + 1)).
@@ -414,7 +420,8 @@ public partial class Dump
ByteSize.FromBytes(512 * (romSectors + 1)). ByteSize.FromBytes(512 * (romSectors + 1)).
Per(imageWriteDuration.Seconds()))); Per(imageWriteDuration.Seconds())));
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, (end - start).Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
_dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(512 * (romSectors + 1)).Per(totalDuration.Milliseconds()). ByteSize.FromBytes(512 * (romSectors + 1)).Per(totalDuration.Milliseconds()).
@@ -442,10 +449,12 @@ public partial class Dump
_dumpLog.WriteLine(Localization.Core.Closing_output_file); _dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
DateTime closeStart = DateTime.Now; _imageCloseStopwatch.Restart();
outputBai.Close(); outputBai.Close();
DateTime closeEnd = DateTime.Now; _imageCloseStopwatch.Stop();
_dumpLog.WriteLine(Localization.Core.Closed_in_0, (closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Closed_in_0,
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
if(_aborted) if(_aborted)
{ {
@@ -465,11 +474,11 @@ public partial class Dump
UpdateStatus?. UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second), _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(512 * (romSectors + 1)).Per(totalDuration.Milliseconds()). ByteSize.FromBytes(512 * (romSectors + 1)).Per(totalDuration.Milliseconds()).

View File

@@ -30,7 +30,6 @@
// Copyright © 2011-2023 Natalia Portillo // Copyright © 2011-2023 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -81,7 +80,7 @@ partial class Dump
return; return;
} }
DateTime chkStart = DateTime.UtcNow; _sidecarStopwatch.Restart();
// ReSharper disable once UseObjectOrCollectionInitializer // ReSharper disable once UseObjectOrCollectionInitializer
_sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding); _sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding);
@@ -93,13 +92,15 @@ partial class Dump
_sidecarClass.EndProgressEvent2 += EndProgress2; _sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus; _sidecarClass.UpdateStatusEvent += UpdateStatus;
Metadata sidecar = _sidecarClass.Create(); Metadata sidecar = _sidecarClass.Create();
DateTime end = DateTime.UtcNow; _sidecarStopwatch.Stop();
if(_aborted) if(_aborted)
return; return;
totalChkDuration = (end - chkStart).TotalMilliseconds; totalChkDuration = _sidecarStopwatch.Elapsed.TotalMilliseconds;
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, (end - chkStart).Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0,
_sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()). ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()).

View File

@@ -63,12 +63,10 @@ partial class Dump
bool sense; bool sense;
byte scsiMediumType = 0; byte scsiMediumType = 0;
const ushort sbcProfile = 0x0001; const ushort sbcProfile = 0x0001;
DateTime start; double totalDuration = 0;
DateTime end; double currentSpeed = 0;
double totalDuration = 0; double maxSpeed = double.MinValue;
double currentSpeed = 0; double minSpeed = double.MaxValue;
double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue;
byte[] readBuffer; byte[] readBuffer;
Modes.DecodedMode? decMode = null; Modes.DecodedMode? decMode = null;
Dictionary<MediaTagType, byte[]> mediaTags = new(); Dictionary<MediaTagType, byte[]> mediaTags = new();
@@ -250,7 +248,7 @@ partial class Dump
return; return;
} }
start = DateTime.UtcNow; _dumpStopwatch.Restart();
double imageWriteDuration = 0; double imageWriteDuration = 0;
if(decMode?.Pages != null) if(decMode?.Pages != null)
@@ -351,7 +349,7 @@ partial class Dump
} }
bool newTrim = false; bool newTrim = false;
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -391,9 +389,9 @@ partial class Dump
{ {
mhddLog.Write(i, cmdDuration, blocksToRead); mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(readBuffer, i, blocksToRead); outputFormat.WriteSectors(readBuffer, i, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true); extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead); _mediaGraph?.PaintSectorsGood(i, blocksToRead);
} }
@@ -407,9 +405,9 @@ partial class Dump
_skip = (uint)(blocks - i); _skip = (uint)(blocks - i);
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) for(ulong b = i; b < i + _skip; b++)
_resume.BadBlocks.Add(b); _resume.BadBlocks.Add(b);
@@ -422,30 +420,32 @@ partial class Dump
newTrim = true; newTrim = true;
} }
_writeStopwatch.Stop();
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
_resume.NextBlock = i + blocksToRead; _resume.NextBlock = i + blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_speedStopwatch.Stop();
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
end = DateTime.UtcNow; _dumpStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -456,7 +456,7 @@ partial class Dump
Per(imageWriteDuration.Seconds()))); Per(imageWriteDuration.Seconds())));
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -472,7 +472,7 @@ partial class Dump
_trim && _trim &&
newTrim) newTrim)
{ {
start = DateTime.UtcNow; _trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors); UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
_dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors); _dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors);
@@ -504,13 +504,13 @@ partial class Dump
} }
EndProgress?.Invoke(); EndProgress?.Invoke();
end = DateTime.UtcNow; _trimStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
} }
#endregion Trimming #endregion Trimming
@@ -727,14 +727,15 @@ partial class Dump
_dumpLog.WriteLine(Localization.Core.Closing_output_file); _dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
DateTime closeStart = DateTime.Now; _imageCloseStopwatch.Restart();
outputFormat.Close(); outputFormat.Close();
DateTime closeEnd = DateTime.Now; _imageCloseStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(Localization.Core.Closed_in_0, (closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Closed_in_0,
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
if(_aborted) if(_aborted)
{ {
@@ -762,7 +763,7 @@ partial class Dump
return; return;
} }
DateTime chkStart = DateTime.UtcNow; _sidecarStopwatch.Restart();
_sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding); _sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding);
_sidecarClass.InitProgressEvent += InitProgress; _sidecarClass.InitProgressEvent += InitProgress;
_sidecarClass.UpdateProgressEvent += UpdateProgress; _sidecarClass.UpdateProgressEvent += UpdateProgress;
@@ -772,21 +773,21 @@ partial class Dump
_sidecarClass.EndProgressEvent2 += EndProgress2; _sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus; _sidecarClass.UpdateStatusEvent += UpdateStatus;
Metadata sidecar = _sidecarClass.Create(); Metadata sidecar = _sidecarClass.Create();
end = DateTime.UtcNow; _sidecarStopwatch.Stop();
if(!_aborted) if(!_aborted)
{ {
totalChkDuration = (end - chkStart).TotalMilliseconds; totalChkDuration = _sidecarStopwatch.Elapsed.TotalMilliseconds;
UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0,
(end - chkStart).Humanize(minUnit: TimeUnit.Second))); _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()))); Per(totalChkDuration.Milliseconds())));
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0,
(end - chkStart).Humanize(minUnit: TimeUnit.Second)); _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()). ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()).
@@ -866,11 +867,11 @@ partial class Dump
UpdateStatus?. UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second), _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).

View File

@@ -66,8 +66,6 @@ public partial class Dump
double maxSpeed = double.MinValue; double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue; double minSpeed = double.MaxValue;
uint blocksToRead = 64; uint blocksToRead = 64;
DateTime start;
DateTime end;
MediaType dskType; MediaType dskType;
bool sense; bool sense;
byte[] senseBuf; byte[] senseBuf;
@@ -145,7 +143,7 @@ public partial class Dump
return; return;
} }
start = DateTime.UtcNow; _dumpStopwatch.Restart();
double imageWriteDuration = 0; double imageWriteDuration = 0;
DumpHardware currentTry = null; DumpHardware currentTry = null;
@@ -184,7 +182,7 @@ public partial class Dump
bool newTrim = false; bool newTrim = false;
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -224,9 +222,9 @@ public partial class Dump
{ {
mhddLog.Write(i, cmdDuration, blocksToRead); mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(readBuffer, i, blocksToRead); outputFormat.WriteSectors(readBuffer, i, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true); extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead); _mediaGraph?.PaintSectorsGood(i, blocksToRead);
} }
@@ -242,9 +240,9 @@ public partial class Dump
_skip = (uint)(blocks - i); _skip = (uint)(blocks - i);
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) for(ulong b = i; b < i + _skip; b++)
_resume.BadBlocks.Add(b); _resume.BadBlocks.Add(b);
@@ -257,30 +255,32 @@ public partial class Dump
newTrim = true; newTrim = true;
} }
_writeStopwatch.Stop();
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
_resume.NextBlock = i + blocksToRead; _resume.NextBlock = i + blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_speedStopwatch.Stop();
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
end = DateTime.UtcNow; _dumpStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -291,7 +291,7 @@ public partial class Dump
Per(imageWriteDuration.Seconds()))); Per(imageWriteDuration.Seconds())));
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -307,7 +307,7 @@ public partial class Dump
_trim && _trim &&
newTrim) newTrim)
{ {
start = DateTime.UtcNow; _trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors); UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
_dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors); _dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors);
@@ -344,10 +344,10 @@ public partial class Dump
} }
EndProgress?.Invoke(); EndProgress?.Invoke();
end = DateTime.UtcNow; _trimStopwatch.Stop();
_dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
} }
#endregion Trimming #endregion Trimming
@@ -581,14 +581,15 @@ public partial class Dump
_dumpLog.WriteLine(Localization.Core.Closing_output_file); _dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
DateTime closeStart = DateTime.Now; _imageCloseStopwatch.Restart();
outputFormat.Close(); outputFormat.Close();
DateTime closeEnd = DateTime.Now; _imageCloseStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(Localization.Core.Closed_in_0, (closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Closed_in_0,
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
if(_aborted) if(_aborted)
{ {
@@ -616,7 +617,7 @@ public partial class Dump
return; return;
} }
DateTime chkStart = DateTime.UtcNow; _sidecarStopwatch.Restart();
_sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding); _sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding);
_sidecarClass.InitProgressEvent += InitProgress; _sidecarClass.InitProgressEvent += InitProgress;
_sidecarClass.UpdateProgressEvent += UpdateProgress; _sidecarClass.UpdateProgressEvent += UpdateProgress;
@@ -626,21 +627,21 @@ public partial class Dump
_sidecarClass.EndProgressEvent2 += EndProgress2; _sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus; _sidecarClass.UpdateStatusEvent += UpdateStatus;
Metadata sidecar = _sidecarClass.Create(); Metadata sidecar = _sidecarClass.Create();
end = DateTime.UtcNow; _sidecarStopwatch.Stop();
if(!_aborted) if(!_aborted)
{ {
totalChkDuration = (end - chkStart).TotalMilliseconds; totalChkDuration = _sidecarStopwatch.Elapsed.TotalMilliseconds;
UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0,
(end - chkStart).Humanize(minUnit: TimeUnit.Second))); _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()))); Per(totalChkDuration.Milliseconds())));
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0,
(end - chkStart).Humanize(minUnit: TimeUnit.Second)); _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()). ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()).
@@ -709,11 +710,11 @@ public partial class Dump
UpdateStatus?. UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second), _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).

View File

@@ -66,8 +66,6 @@ public partial class Dump
double currentSpeed = 0; double currentSpeed = 0;
double maxSpeed = double.MinValue; double maxSpeed = double.MinValue;
double minSpeed = double.MaxValue; double minSpeed = double.MaxValue;
DateTime start;
DateTime end;
byte[] senseBuf; byte[] senseBuf;
if(_outputPlugin is not IWritableOpticalImage outputOptical) if(_outputPlugin is not IWritableOpticalImage outputOptical)
@@ -153,7 +151,7 @@ public partial class Dump
return; return;
} }
start = DateTime.UtcNow; _dumpStopwatch.Restart();
double imageWriteDuration = 0; double imageWriteDuration = 0;
outputOptical.SetTracks(new List<Track> outputOptical.SetTracks(new List<Track>
@@ -206,7 +204,7 @@ public partial class Dump
bool newTrim = false; bool newTrim = false;
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -241,14 +239,15 @@ public partial class Dump
totalDuration += cmdDuration; totalDuration += cmdDuration;
_writeStopwatch.Restart();
if(!sense && if(!sense &&
!_dev.Error) !_dev.Error)
{ {
mhddLog.Write(i, cmdDuration, blocksToRead); mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
DateTime writeStart = DateTime.Now;
outputOptical.WriteSectors(readBuffer, i, blocksToRead); outputOptical.WriteSectors(readBuffer, i, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true); extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead); _mediaGraph?.PaintSectorsGood(i, blocksToRead);
} }
@@ -264,9 +263,8 @@ public partial class Dump
_skip = (uint)(blocks - i); _skip = (uint)(blocks - i);
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now;
outputOptical.WriteSectors(new byte[blockSize * _skip], i, _skip); outputOptical.WriteSectors(new byte[blockSize * _skip], i, _skip);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) for(ulong b = i; b < i + _skip; b++)
_resume.BadBlocks.Add(b); _resume.BadBlocks.Add(b);
@@ -279,30 +277,31 @@ public partial class Dump
newTrim = true; newTrim = true;
} }
_writeStopwatch.Stop();
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
_resume.NextBlock = i + blocksToRead; _resume.NextBlock = i + blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
end = DateTime.UtcNow; _dumpStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -313,7 +312,7 @@ public partial class Dump
Per(imageWriteDuration.Seconds()))); Per(imageWriteDuration.Seconds())));
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -329,7 +328,7 @@ public partial class Dump
_trim && _trim &&
newTrim) newTrim)
{ {
start = DateTime.UtcNow; _trimStopwatch.Restart();
_dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors); _dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors);
ulong[] tmpArray = _resume.BadBlocks.ToArray(); ulong[] tmpArray = _resume.BadBlocks.ToArray();
@@ -364,10 +363,10 @@ public partial class Dump
} }
EndProgress?.Invoke(); EndProgress?.Invoke();
end = DateTime.UtcNow; _trimStopwatch.Stop();
_dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
} }
#endregion Trimming #endregion Trimming
@@ -587,10 +586,12 @@ public partial class Dump
_dumpLog.WriteLine(Localization.Core.Closing_output_file); _dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
DateTime closeStart = DateTime.Now; _imageCloseStopwatch.Restart();
outputOptical.Close(); outputOptical.Close();
DateTime closeEnd = DateTime.Now; _imageCloseStopwatch.Stop();
_dumpLog.WriteLine(Localization.Core.Closed_in_0, (closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Closed_in_0,
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
if(_aborted) if(_aborted)
{ {
@@ -609,11 +610,11 @@ public partial class Dump
UpdateStatus?. UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second), _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).

View File

@@ -67,8 +67,6 @@ partial class Dump
uint blockSize; uint blockSize;
ulong blocks = 0; ulong blocks = 0;
MediaType dskType; MediaType dskType;
DateTime start;
DateTime end;
double totalDuration = 0; double totalDuration = 0;
double currentSpeed = 0; double currentSpeed = 0;
double maxSpeed = double.MinValue; double maxSpeed = double.MinValue;
@@ -796,7 +794,7 @@ partial class Dump
return; return;
} }
start = DateTime.UtcNow; _dumpStopwatch.Restart();
var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, 1, _private); var mhddLog = new MhddLog(_outputPrefix + ".mhddlog.bin", _dev, blocks, blockSize, 1, _private);
var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0008); var ibgLog = new IbgLog(_outputPrefix + ".ibg", 0x0008);
@@ -832,12 +830,13 @@ partial class Dump
if(mode10Data != null) if(mode10Data != null)
outputTape.WriteMediaTag(mode10Data, MediaTagType.SCSI_MODESENSE_10); outputTape.WriteMediaTag(mode10Data, MediaTagType.SCSI_MODESENSE_10);
DateTime timeSpeedStart = DateTime.UtcNow;
ulong currentSpeedSize = 0; ulong currentSpeedSize = 0;
double imageWriteDuration = 0; double imageWriteDuration = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
_speedStopwatch.Restart();
while(currentPartition < totalPartitions) while(currentPartition < totalPartitions)
{ {
if(_aborted) if(_aborted)
@@ -1053,9 +1052,9 @@ partial class Dump
return; // TODO: Return more cleanly return; // TODO: Return more cleanly
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputTape.WriteSector(new byte[blockSize], currentBlock); outputTape.WriteSector(new byte[blockSize], currentBlock);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration); mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration);
ibgLog.Write(currentBlock, 0); ibgLog.Write(currentBlock, 0);
@@ -1065,29 +1064,31 @@ partial class Dump
{ {
mhddLog.Write(currentBlock, duration); mhddLog.Write(currentBlock, duration);
ibgLog.Write(currentBlock, currentSpeed * 1024); ibgLog.Write(currentBlock, currentSpeed * 1024);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputTape.WriteSector(cmdBuf, currentBlock); outputTape.WriteSector(cmdBuf, currentBlock);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(currentBlock, 1, true); extents.Add(currentBlock, 1, true);
} }
_writeStopwatch.Stop();
currentBlock++; currentBlock++;
_resume.NextBlock++; _resume.NextBlock++;
currentSpeedSize += blockSize; currentSpeedSize += blockSize;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = currentSpeedSize / (1048576 * elapsed); currentSpeed = currentSpeedSize / (1048576 * elapsed);
currentSpeedSize = 0; currentSpeedSize = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
blocks = currentBlock + 1; blocks = currentBlock + 1;
end = DateTime.UtcNow; _speedStopwatch.Stop();
_dumpStopwatch.Stop();
// If not aborted this is added at the end of medium // If not aborted this is added at the end of medium
if(_aborted) if(_aborted)
@@ -1102,11 +1103,11 @@ partial class Dump
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -1117,7 +1118,7 @@ partial class Dump
Per(imageWriteDuration.Seconds()))); Per(imageWriteDuration.Seconds())));
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -1323,14 +1324,15 @@ partial class Dump
_dumpLog.WriteLine(Localization.Core.Closing_output_file); _dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
DateTime closeStart = DateTime.Now; _imageCloseStopwatch.Restart();
outputTape.Close(); outputTape.Close();
DateTime closeEnd = DateTime.Now; _imageCloseStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(Localization.Core.Closed_in_0, (closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Closed_in_0,
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
if(_aborted) if(_aborted)
{ {
@@ -1366,7 +1368,7 @@ partial class Dump
return; return;
} }
DateTime chkStart = DateTime.UtcNow; _sidecarStopwatch.Restart();
_sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding); _sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding);
_sidecarClass.InitProgressEvent += InitProgress; _sidecarClass.InitProgressEvent += InitProgress;
_sidecarClass.UpdateProgressEvent += UpdateProgress; _sidecarClass.UpdateProgressEvent += UpdateProgress;
@@ -1376,21 +1378,21 @@ partial class Dump
_sidecarClass.EndProgressEvent2 += EndProgress2; _sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus; _sidecarClass.UpdateStatusEvent += UpdateStatus;
Metadata sidecar = _sidecarClass.Create(); Metadata sidecar = _sidecarClass.Create();
end = DateTime.UtcNow; _sidecarStopwatch.Stop();
if(!_aborted) if(!_aborted)
{ {
totalChkDuration = (end - chkStart).TotalMilliseconds; totalChkDuration = _sidecarStopwatch.ElapsedMilliseconds;
UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0,
(end - chkStart).Humanize(minUnit: TimeUnit.Second))); _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()))); Per(totalChkDuration.Milliseconds())));
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0,
(end - chkStart).Humanize(minUnit: TimeUnit.Second)); _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()). ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()).
@@ -1471,11 +1473,11 @@ partial class Dump
UpdateStatus?. UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second), _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).

View File

@@ -25,7 +25,6 @@
// Copyright © 2020-2023 Rebecca Wallander // Copyright © 2020-2023 Rebecca Wallander
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.Linq; using System.Linq;
using Aaru.CommonTypes.AaruMetadata; using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Enums;
@@ -71,7 +70,6 @@ partial class Dump
{ {
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
bool sense; bool sense;
DateTime timeSpeedStart = DateTime.UtcNow;
byte[] buffer; byte[] buffer;
uint blocksToRead = maxBlocksToRead; uint blocksToRead = maxBlocksToRead;
var outputFormat = _outputPlugin as IWritableImage; var outputFormat = _outputPlugin as IWritableImage;
@@ -212,9 +210,9 @@ partial class Dump
mhddLog.Write(i, cmdDuration, blocksToRead); mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(buffer, i, blocksToRead); outputFormat.WriteSectors(buffer, i, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true); extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead); _mediaGraph?.PaintSectorsGood(i, blocksToRead);
} }
@@ -244,9 +242,9 @@ partial class Dump
_skip = (uint)(blocks - i); _skip = (uint)(blocks - i);
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) for(ulong b = i; b < i + _skip; b++)
_resume.BadBlocks.Add(b); _resume.BadBlocks.Add(b);
@@ -259,19 +257,21 @@ partial class Dump
newTrim = true; newTrim = true;
} }
_writeStopwatch.Stop();
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
_resume.NextBlock = i + blocksToRead; _resume.NextBlock = i + blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_speedStopwatch.Stop();
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
EndProgress?.Invoke(); EndProgress?.Invoke();

View File

@@ -80,13 +80,11 @@ partial class Dump
byte scsiDensityCode = 0; byte scsiDensityCode = 0;
bool containsFloppyPage = false; bool containsFloppyPage = false;
const ushort sbcProfile = 0x0001; const ushort sbcProfile = 0x0001;
DateTime start; double totalDuration = 0;
DateTime end; double currentSpeed = 0;
double totalDuration = 0; double maxSpeed = double.MinValue;
double currentSpeed = 0; double minSpeed = double.MaxValue;
double maxSpeed = double.MinValue; Modes.DecodedMode? decMode = null;
double minSpeed = double.MaxValue;
Modes.DecodedMode? decMode = null;
bool ret; bool ret;
ExtentsULong blankExtents = null; ExtentsULong blankExtents = null;
var outputFormat = _outputPlugin as IWritableImage; var outputFormat = _outputPlugin as IWritableImage;
@@ -363,7 +361,7 @@ partial class Dump
imageCreated = true; imageCreated = true;
} }
start = DateTime.UtcNow; _dumpStopwatch.Restart();
double imageWriteDuration = 0; double imageWriteDuration = 0;
bool writeSingleOpticalTrack = true; bool writeSingleOpticalTrack = true;
@@ -759,14 +757,14 @@ partial class Dump
mediaTags.ContainsKey(MediaTagType.DVD_DiscKey_Decrypted) mediaTags.ContainsKey(MediaTagType.DVD_DiscKey_Decrypted)
? mediaTags[MediaTagType.DVD_DiscKey_Decrypted] : null); ? mediaTags[MediaTagType.DVD_DiscKey_Decrypted] : null);
end = DateTime.UtcNow; _dumpStopwatch.Stop();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -777,7 +775,7 @@ partial class Dump
Per(imageWriteDuration.Seconds()))); Per(imageWriteDuration.Seconds())));
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -793,7 +791,7 @@ partial class Dump
_trim && _trim &&
newTrim) newTrim)
{ {
start = DateTime.UtcNow; _trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors); UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
_dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors); _dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors);
@@ -802,13 +800,15 @@ partial class Dump
TrimSbcData(scsiReader, extents, currentTry, blankExtents); TrimSbcData(scsiReader, extents, currentTry, blankExtents);
EndProgress?.Invoke(); EndProgress?.Invoke();
end = DateTime.UtcNow; _trimStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_trimStopwatch.Stop();
} }
#endregion Trimming #endregion Trimming
@@ -1010,14 +1010,15 @@ partial class Dump
_dumpLog.WriteLine(Localization.Core.Closing_output_file); _dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
DateTime closeStart = DateTime.Now; _imageCloseStopwatch.Restart();
outputFormat.Close(); outputFormat.Close();
DateTime closeEnd = DateTime.Now; _imageCloseStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(Localization.Core.Closed_in_0, (closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Closed_in_0,
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
if(_aborted) if(_aborted)
{ {
@@ -1051,7 +1052,7 @@ partial class Dump
return; return;
} }
DateTime chkStart = DateTime.UtcNow; _sidecarStopwatch.Restart();
_sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding); _sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding);
_sidecarClass.InitProgressEvent += InitProgress; _sidecarClass.InitProgressEvent += InitProgress;
_sidecarClass.UpdateProgressEvent += UpdateProgress; _sidecarClass.UpdateProgressEvent += UpdateProgress;
@@ -1061,21 +1062,21 @@ partial class Dump
_sidecarClass.EndProgressEvent2 += EndProgress2; _sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus; _sidecarClass.UpdateStatusEvent += UpdateStatus;
Metadata sidecar = _sidecarClass.Create(); Metadata sidecar = _sidecarClass.Create();
end = DateTime.UtcNow; _sidecarStopwatch.Stop();
if(!_aborted) if(!_aborted)
{ {
totalChkDuration = (end - chkStart).TotalMilliseconds; totalChkDuration = _sidecarStopwatch.Elapsed.TotalMilliseconds;
UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0,
(end - chkStart).Humanize(minUnit: TimeUnit.Second))); _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()))); Per(totalChkDuration.Milliseconds())));
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0,
(end - chkStart).Humanize(minUnit: TimeUnit.Second)); _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -1295,11 +1296,11 @@ partial class Dump
UpdateStatus?. UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second), _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).

View File

@@ -53,7 +53,6 @@ partial class Dump
bool sense; bool sense;
byte[] buffer; byte[] buffer;
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
DateTime timeSpeedStart = DateTime.UtcNow;
bool canMediumScan = true; bool canMediumScan = true;
var outputFormat = _outputPlugin as IWritableImage; var outputFormat = _outputPlugin as IWritableImage;
@@ -185,6 +184,8 @@ partial class Dump
if(extent.Item1 < _resume.NextBlock) if(extent.Item1 < _resume.NextBlock)
nextBlock = (uint)_resume.NextBlock; nextBlock = (uint)_resume.NextBlock;
_speedStopwatch.Restart();
for(ulong i = nextBlock; i <= extent.Item2; i += blocksToRead) for(ulong i = nextBlock; i <= extent.Item2; i += blocksToRead)
{ {
if(_aborted) if(_aborted)
@@ -219,9 +220,9 @@ partial class Dump
{ {
mhddLog.Write(i, cmdDuration, blocksToRead); mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(buffer, i, blocksToRead); outputFormat.WriteSectors(buffer, i, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true); extents.Add(i, blocksToRead, true);
} }
else else
@@ -234,9 +235,9 @@ partial class Dump
_skip = (uint)(extent.Item2 + 1 - i); _skip = (uint)(extent.Item2 + 1 - i);
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) for(ulong b = i; b < i + _skip; b++)
_resume.BadBlocks.Add(b); _resume.BadBlocks.Add(b);
@@ -249,20 +250,22 @@ partial class Dump
newTrim = true; newTrim = true;
} }
_writeStopwatch.Stop();
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
_resume.NextBlock = i + blocksToRead; _resume.NextBlock = i + blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
} }
_speedStopwatch.Stop();
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
EndProgress?.Invoke(); EndProgress?.Invoke();

View File

@@ -248,8 +248,6 @@ public partial class Dump
else else
mediaTags.Add(_dev.Type == DeviceType.SecureDigital ? MediaTagType.SD_CID : MediaTagType.MMC_CID, null); mediaTags.Add(_dev.Type == DeviceType.SecureDigital ? MediaTagType.SD_CID : MediaTagType.MMC_CID, null);
DateTime start;
DateTime end;
double totalDuration = 0; double totalDuration = 0;
double currentSpeed = 0; double currentSpeed = 0;
double maxSpeed = double.MinValue; double maxSpeed = double.MinValue;
@@ -620,10 +618,10 @@ public partial class Dump
_mediaGraph?.PaintSectorsBad(_resume.BadBlocks); _mediaGraph?.PaintSectorsBad(_resume.BadBlocks);
} }
start = DateTime.UtcNow; _dumpStopwatch.Restart();
_speedStopwatch.Restart();
double imageWriteDuration = 0; double imageWriteDuration = 0;
bool newTrim = false; bool newTrim = false;
DateTime timeSpeedStart = DateTime.UtcNow;
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -670,9 +668,9 @@ public partial class Dump
{ {
mhddLog.Write(i, duration, blocksToRead); mhddLog.Write(i, duration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(cmdBuf, i, blocksToRead); outputFormat.WriteSectors(cmdBuf, i, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true); extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead); _mediaGraph?.PaintSectorsGood(i, blocksToRead);
} }
@@ -689,38 +687,40 @@ public partial class Dump
mhddLog.Write(i, duration < 500 ? 65535 : duration, _skip); mhddLog.Write(i, duration < 500 ? 65535 : duration, _skip);
ibgLog.Write(i, 0); ibgLog.Write(i, 0);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
_dumpLog.WriteLine(Localization.Core.Skipping_0_blocks_from_errored_block_1, _skip, i); _dumpLog.WriteLine(Localization.Core.Skipping_0_blocks_from_errored_block_1, _skip, i);
i += _skip - blocksToRead; i += _skip - blocksToRead;
newTrim = true; newTrim = true;
} }
_writeStopwatch.Stop();
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
_resume.NextBlock = i + blocksToRead; _resume.NextBlock = i + blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
end = DateTime.Now; _speedStopwatch.Stop();
_dumpStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -731,7 +731,7 @@ public partial class Dump
Per(imageWriteDuration.Seconds()))); Per(imageWriteDuration.Seconds())));
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -747,7 +747,7 @@ public partial class Dump
_trim && _trim &&
newTrim) newTrim)
{ {
start = DateTime.UtcNow; _trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors); UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
_dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors); _dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors);
@@ -786,13 +786,13 @@ public partial class Dump
} }
EndProgress?.Invoke(); EndProgress?.Invoke();
end = DateTime.UtcNow; _trimStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
} }
#endregion Trimming #endregion Trimming
@@ -886,14 +886,15 @@ public partial class Dump
_dumpLog.WriteLine(Localization.Core.Closing_output_file); _dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
DateTime closeStart = DateTime.Now; _imageCloseStopwatch.Restart();
outputFormat.Close(); outputFormat.Close();
DateTime closeEnd = DateTime.Now; _imageCloseStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(Localization.Core.Closed_in_0, (closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Closed_in_0,
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
if(_aborted) if(_aborted)
{ {
@@ -917,7 +918,7 @@ public partial class Dump
if(opened != ErrorNumber.NoError) if(opened != ErrorNumber.NoError)
StoppingErrorMessage?.Invoke(string.Format(Localization.Core.Error_0_opening_created_image, opened)); StoppingErrorMessage?.Invoke(string.Format(Localization.Core.Error_0_opening_created_image, opened));
DateTime chkStart = DateTime.UtcNow; _sidecarStopwatch.Restart();
_sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding); _sidecarClass = new Sidecar(inputPlugin, _outputPath, filter.Id, _encoding);
_sidecarClass.InitProgressEvent += InitProgress; _sidecarClass.InitProgressEvent += InitProgress;
_sidecarClass.UpdateProgressEvent += UpdateProgress; _sidecarClass.UpdateProgressEvent += UpdateProgress;
@@ -927,6 +928,7 @@ public partial class Dump
_sidecarClass.EndProgressEvent2 += EndProgress2; _sidecarClass.EndProgressEvent2 += EndProgress2;
_sidecarClass.UpdateStatusEvent += UpdateStatus; _sidecarClass.UpdateStatusEvent += UpdateStatus;
Metadata sidecar = _sidecarClass.Create(); Metadata sidecar = _sidecarClass.Create();
_sidecarStopwatch.Stop();
if(!_aborted) if(!_aborted)
{ {
@@ -936,19 +938,17 @@ public partial class Dump
sidecar = _preSidecar; sidecar = _preSidecar;
} }
end = DateTime.UtcNow; totalChkDuration = _sidecarStopwatch.Elapsed.TotalMilliseconds;
totalChkDuration = (end - chkStart).TotalMilliseconds;
UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0,
(end - chkStart).Humanize(minUnit: TimeUnit.Second))); _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()))); Per(totalChkDuration.Milliseconds())));
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0,
(end - chkStart).Humanize(minUnit: TimeUnit.Second)); _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()). ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()).
@@ -1004,11 +1004,11 @@ public partial class Dump
UpdateStatus?. UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second), _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).

View File

@@ -72,8 +72,6 @@ partial class Dump
bool sense; bool sense;
const uint blockSize = 2048; const uint blockSize = 2048;
uint blocksToRead = 64; uint blocksToRead = 64;
DateTime start;
DateTime end;
double totalDuration = 0; double totalDuration = 0;
double currentSpeed = 0; double currentSpeed = 0;
double maxSpeed = double.MinValue; double maxSpeed = double.MinValue;
@@ -520,7 +518,7 @@ partial class Dump
return; return;
} }
start = DateTime.UtcNow; _dumpStopwatch.Restart();
double imageWriteDuration = 0; double imageWriteDuration = 0;
double cmdDuration = 0; double cmdDuration = 0;
@@ -577,7 +575,7 @@ partial class Dump
_dumpLog.WriteLine(Localization.Core.Reading_game_partition); _dumpLog.WriteLine(Localization.Core.Reading_game_partition);
UpdateStatus?.Invoke(Localization.Core.Reading_game_partition); UpdateStatus?.Invoke(Localization.Core.Reading_game_partition);
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -662,9 +660,9 @@ partial class Dump
{ {
mhddLog.Write(i, cmdDuration, blocksToRead); mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(readBuffer, i, blocksToRead); outputFormat.WriteSectors(readBuffer, i, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true); extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead); _mediaGraph?.PaintSectorsGood(i, blocksToRead);
} }
@@ -680,9 +678,9 @@ partial class Dump
_skip = (uint)(blocks - i); _skip = (uint)(blocks - i);
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip); outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) for(ulong b = i; b < i + _skip; b++)
_resume.BadBlocks.Add(b); _resume.BadBlocks.Add(b);
@@ -708,21 +706,24 @@ partial class Dump
newTrim = true; newTrim = true;
} }
_writeStopwatch.Stop();
blocksToRead = saveBlocksToRead; blocksToRead = saveBlocksToRead;
currentSector = i + 1; currentSector = i + 1;
_resume.NextBlock = currentSector; _resume.NextBlock = currentSector;
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
_speedStopwatch.Stop();
for(ulong i = extentStart; i <= extentEnd; i += blocksToRead) for(ulong i = extentStart; i <= extentEnd; i += blocksToRead)
{ {
saveBlocksToRead = blocksToRead; saveBlocksToRead = blocksToRead;
@@ -743,9 +744,9 @@ partial class Dump
ibgLog.Write(i, currentSpeed * 1024); ibgLog.Write(i, currentSpeed * 1024);
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * blocksToRead], i, blocksToRead); outputFormat.WriteSectors(new byte[blockSize * blocksToRead], i, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
blocksToRead = saveBlocksToRead; blocksToRead = saveBlocksToRead;
extents.Add(i, blocksToRead, true); extents.Add(i, blocksToRead, true);
currentSector = i + 1; currentSector = i + 1;
@@ -757,6 +758,7 @@ partial class Dump
currentSector = extentEnd + 1; currentSector = extentEnd + 1;
} }
_writeStopwatch.Stop();
_resume.BadBlocks = _resume.BadBlocks.Distinct().ToList(); _resume.BadBlocks = _resume.BadBlocks.Distinct().ToList();
EndProgress?.Invoke(); EndProgress?.Invoke();
@@ -788,10 +790,11 @@ partial class Dump
ibgLog.Write(middle + currentSector, currentSpeed * 1024); ibgLog.Write(middle + currentSector, currentSpeed * 1024);
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * blocksToRead], middle + currentSector, blocksToRead); outputFormat.WriteSectors(new byte[blockSize * blocksToRead], middle + currentSector, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(currentSector, blocksToRead, true); extents.Add(currentSector, blocksToRead, true);
_writeStopwatch.Stop();
currentSector += blocksToRead; currentSector += blocksToRead;
_resume.NextBlock = currentSector; _resume.NextBlock = currentSector;
@@ -863,9 +866,9 @@ partial class Dump
{ {
mhddLog.Write(currentSector, cmdDuration, blocksToRead); mhddLog.Write(currentSector, cmdDuration, blocksToRead);
ibgLog.Write(currentSector, currentSpeed * 1024); ibgLog.Write(currentSector, currentSpeed * 1024);
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(readBuffer, currentSector, blocksToRead); outputFormat.WriteSectors(readBuffer, currentSector, blocksToRead);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(currentSector, blocksToRead, true); extents.Add(currentSector, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(currentSector, blocksToRead); _mediaGraph?.PaintSectorsGood(currentSector, blocksToRead);
} }
@@ -878,9 +881,9 @@ partial class Dump
return; // TODO: Return more cleanly return; // TODO: Return more cleanly
// Write empty data // Write empty data
DateTime writeStart = DateTime.Now; _writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], currentSector, _skip); outputFormat.WriteSectors(new byte[blockSize * _skip], currentSector, _skip);
imageWriteDuration += (DateTime.Now - writeStart).TotalSeconds; imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
// TODO: Handle errors in video partition // TODO: Handle errors in video partition
//errored += blocksToRead; //errored += blocksToRead;
@@ -901,18 +904,20 @@ partial class Dump
_dumpLog.WriteLine(senseLine); _dumpLog.WriteLine(senseLine);
} }
_writeStopwatch.Stop();
currentSector += blocksToRead; currentSector += blocksToRead;
_resume.NextBlock = currentSector; _resume.NextBlock = currentSector;
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
EndProgress?.Invoke(); EndProgress?.Invoke();
@@ -939,15 +944,15 @@ partial class Dump
return; return;
} }
end = DateTime.UtcNow; _dumpStopwatch.Stop();
AaruConsole.WriteLine(); AaruConsole.WriteLine();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, blocks, blockSize, _dumpStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -958,7 +963,7 @@ partial class Dump
Per(imageWriteDuration.Seconds()))); Per(imageWriteDuration.Seconds())));
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).
@@ -974,7 +979,7 @@ partial class Dump
_trim && _trim &&
newTrim) newTrim)
{ {
start = DateTime.UtcNow; _trimStopwatch.Restart();
UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors); UpdateStatus?.Invoke(Localization.Core.Trimming_skipped_sectors);
_dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors); _dumpLog.WriteLine(Localization.Core.Trimming_skipped_sectors);
@@ -1012,13 +1017,13 @@ partial class Dump
} }
EndProgress?.Invoke(); EndProgress?.Invoke();
end = DateTime.UtcNow; _trimStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0, _dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second))); _trimStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
} }
#endregion Trimming #endregion Trimming
@@ -1284,14 +1289,15 @@ partial class Dump
_dumpLog.WriteLine(Localization.Core.Closing_output_file); _dumpLog.WriteLine(Localization.Core.Closing_output_file);
UpdateStatus?.Invoke(Localization.Core.Closing_output_file); UpdateStatus?.Invoke(Localization.Core.Closing_output_file);
DateTime closeStart = DateTime.Now; _imageCloseStopwatch.Restart();
outputFormat.Close(); outputFormat.Close();
DateTime closeEnd = DateTime.Now; _imageCloseStopwatch.Stop();
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
_dumpLog.WriteLine(Localization.Core.Closed_in_0, (closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Closed_in_0,
_imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
if(_aborted) if(_aborted)
{ {
@@ -1324,11 +1330,11 @@ partial class Dump
UpdateStatus?. UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing, Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second), _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second), totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second), imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)). ByteSize.FromBytes(blockSize * (blocks + 1)).

View File

@@ -102,8 +102,6 @@ public sealed partial class MediaScan
results.E = 0; // >=150ms, <500ms results.E = 0; // >=150ms, <500ms
results.F = 0; // >=500ms results.F = 0; // >=500ms
results.Errored = 0; results.Errored = 0;
DateTime start;
DateTime end;
results.ProcessingTime = 0; results.ProcessingTime = 0;
double currentSpeed = 0; double currentSpeed = 0;
results.MaxSpeed = double.MinValue; results.MaxSpeed = double.MinValue;
@@ -130,8 +128,8 @@ public sealed partial class MediaScan
mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, blocksToRead, false); mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, blocksToRead, false);
ibgLog = new IbgLog(_ibgLogPath, ataProfile); ibgLog = new IbgLog(_ibgLogPath, ataProfile);
start = DateTime.UtcNow; _scanStopwatch.Restart();
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -206,7 +204,7 @@ public sealed partial class MediaScan
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
@@ -214,14 +212,15 @@ public sealed partial class MediaScan
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
ScanSpeed?.Invoke(i, currentSpeed * 1024); ScanSpeed?.Invoke(i, currentSpeed * 1024);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
end = DateTime.UtcNow; _speedStopwatch.Stop();
_scanStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, results.Blocks, blockSize, _scanStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000),
_devicePath); _devicePath);
@@ -261,8 +260,8 @@ public sealed partial class MediaScan
ulong currentBlock = 0; ulong currentBlock = 0;
results.Blocks = (ulong)(cylinders * heads * sectors); results.Blocks = (ulong)(cylinders * heads * sectors);
start = DateTime.UtcNow; _scanStopwatch.Restart();
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -337,7 +336,7 @@ public sealed partial class MediaScan
sectorSpeedStart++; sectorSpeedStart++;
currentBlock++; currentBlock++;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
@@ -345,16 +344,17 @@ public sealed partial class MediaScan
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
ScanSpeed?.Invoke(currentBlock, currentSpeed * 1024); ScanSpeed?.Invoke(currentBlock, currentSpeed * 1024);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
} }
} }
end = DateTime.UtcNow; _speedStopwatch.Stop();
_scanStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, results.Blocks, blockSize, _scanStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000),
_devicePath); _devicePath);
@@ -391,7 +391,7 @@ public sealed partial class MediaScan
} }
results.ProcessingTime /= 1000; results.ProcessingTime /= 1000;
results.TotalTime = (end - start).TotalSeconds; results.TotalTime = _scanStopwatch.Elapsed.TotalSeconds;
results.AvgSpeed = blockSize * (double)(results.Blocks + 1) / 1048576 / results.ProcessingTime; results.AvgSpeed = blockSize * (double)(results.Blocks + 1) / 1048576 / results.ProcessingTime;
results.SeekTimes = seekTimes; results.SeekTimes = seekTimes;

View File

@@ -31,6 +31,7 @@
// ****************************************************************************/ // ****************************************************************************/
using System; using System;
using System.Diagnostics;
using Aaru.CommonTypes; using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Enums;
using Aaru.Devices; using Aaru.Devices;
@@ -40,14 +41,16 @@ namespace Aaru.Core.Devices.Scanning;
public sealed partial class MediaScan public sealed partial class MediaScan
{ {
readonly Device _dev; readonly Device _dev;
readonly string _devicePath; readonly string _devicePath;
readonly string _ibgLogPath; readonly string _ibgLogPath;
readonly string _mhddLogPath; readonly string _mhddLogPath;
readonly bool _seekTest; readonly bool _seekTest;
readonly bool _useBufferedReads; readonly bool _useBufferedReads;
bool _aborted; bool _aborted;
static readonly TimeSpan _oneSecond = 1.Seconds(); static readonly TimeSpan _oneSecond = 1.Seconds();
readonly Stopwatch _scanStopwatch;
readonly Stopwatch _speedStopwatch;
/// <param name="mhddLogPath">Path to a MHDD log file</param> /// <param name="mhddLogPath">Path to a MHDD log file</param>
/// <param name="ibgLogPath">Path to a IMGBurn log file</param> /// <param name="ibgLogPath">Path to a IMGBurn log file</param>
@@ -68,6 +71,8 @@ public sealed partial class MediaScan
_aborted = false; _aborted = false;
_seekTest = seekTest; _seekTest = seekTest;
_useBufferedReads = useBufferedReads; _useBufferedReads = useBufferedReads;
_scanStopwatch = new Stopwatch();
_speedStopwatch = new Stopwatch();
} }
/// <summary>Starts a media scan</summary> /// <summary>Starts a media scan</summary>

View File

@@ -276,8 +276,6 @@ public sealed partial class MediaScan
results.E = 0; // >=150ms, <500ms results.E = 0; // >=150ms, <500ms
results.F = 0; // >=500ms results.F = 0; // >=500ms
results.Errored = 0; results.Errored = 0;
DateTime start;
DateTime end;
results.ProcessingTime = 0; results.ProcessingTime = 0;
results.TotalTime = 0; results.TotalTime = 0;
double currentSpeed = 0; double currentSpeed = 0;
@@ -309,7 +307,7 @@ public sealed partial class MediaScan
return results; return results;
} }
start = DateTime.UtcNow; _scanStopwatch.Restart();
if(readcd) if(readcd)
while(true) while(true)
@@ -340,7 +338,7 @@ public sealed partial class MediaScan
InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, currentProfile); InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, currentProfile);
mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, blocksToRead, false); mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, blocksToRead, false);
ibgLog = new IbgLog(_ibgLogPath, currentProfile); ibgLog = new IbgLog(_ibgLogPath, currentProfile);
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -459,7 +457,7 @@ public sealed partial class MediaScan
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
@@ -467,14 +465,15 @@ public sealed partial class MediaScan
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
ScanSpeed?.Invoke(i, currentSpeed * 1024); ScanSpeed?.Invoke(i, currentSpeed * 1024);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
end = DateTime.UtcNow; _speedStopwatch.Stop();
_scanStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
currentSpeed = sectorSpeedStart * blockSize / (1048576 * (end - timeSpeedStart).TotalSeconds); currentSpeed = sectorSpeedStart * blockSize / (1048576 * _speedStopwatch.Elapsed.TotalSeconds);
// ReSharper disable once CompareOfFloatsByEqualityOperator // ReSharper disable once CompareOfFloatsByEqualityOperator
if(results.MaxSpeed == double.MinValue) if(results.MaxSpeed == double.MinValue)
@@ -484,20 +483,20 @@ public sealed partial class MediaScan
if(results.MinSpeed == double.MaxValue) if(results.MinSpeed == double.MaxValue)
results.MinSpeed = currentSpeed; results.MinSpeed = currentSpeed;
ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, results.Blocks, blockSize, _scanStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000),
_devicePath); _devicePath);
} }
else else
{ {
start = DateTime.UtcNow; _scanStopwatch.Restart();
UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, scsiReader.BlocksToRead)); UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, scsiReader.BlocksToRead));
InitBlockMap?.Invoke(results.Blocks, blockSize, scsiReader.BlocksToRead, currentProfile); InitBlockMap?.Invoke(results.Blocks, blockSize, scsiReader.BlocksToRead, currentProfile);
mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, scsiReader.BlocksToRead, false); mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, scsiReader.BlocksToRead, false);
ibgLog = new IbgLog(_ibgLogPath, currentProfile); ibgLog = new IbgLog(_ibgLogPath, currentProfile);
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -578,7 +577,7 @@ public sealed partial class MediaScan
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
@@ -586,14 +585,15 @@ public sealed partial class MediaScan
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
ScanSpeed?.Invoke(i, currentSpeed * 1024); ScanSpeed?.Invoke(i, currentSpeed * 1024);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
end = DateTime.UtcNow; _speedStopwatch.Stop();
_scanStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, results.Blocks, blockSize, _scanStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000),
_devicePath); _devicePath);
} }
@@ -642,7 +642,7 @@ public sealed partial class MediaScan
EndProgress?.Invoke(); EndProgress?.Invoke();
results.ProcessingTime /= 1000; results.ProcessingTime /= 1000;
results.TotalTime = (end - start).TotalSeconds; results.TotalTime = _scanStopwatch.Elapsed.TotalSeconds;
results.AvgSpeed = blockSize * (double)(results.Blocks + 1) / 1048576 / results.ProcessingTime; results.AvgSpeed = blockSize * (double)(results.Blocks + 1) / 1048576 / results.ProcessingTime;
results.SeekTimes = seekTimes; results.SeekTimes = seekTimes;

View File

@@ -196,8 +196,6 @@ public sealed partial class MediaScan
results.E = 0; // >=150ms, <500ms results.E = 0; // >=150ms, <500ms
results.F = 0; // >=500ms results.F = 0; // >=500ms
results.Errored = 0; results.Errored = 0;
DateTime start;
DateTime end;
results.ProcessingTime = 0; results.ProcessingTime = 0;
double currentSpeed = 0; double currentSpeed = 0;
results.MaxSpeed = double.MinValue; results.MaxSpeed = double.MinValue;
@@ -223,8 +221,8 @@ public sealed partial class MediaScan
var mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, blocksToRead, false); var mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, blocksToRead, false);
var ibgLog = new IbgLog(_ibgLogPath, sdProfile); var ibgLog = new IbgLog(_ibgLogPath, sdProfile);
start = DateTime.UtcNow; _scanStopwatch.Restart();
DateTime timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
ulong sectorSpeedStart = 0; ulong sectorSpeedStart = 0;
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -311,7 +309,7 @@ public sealed partial class MediaScan
sectorSpeedStart += blocksToRead; sectorSpeedStart += blocksToRead;
double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds; double elapsed = _speedStopwatch.Elapsed.TotalSeconds;
if(elapsed <= 0) if(elapsed <= 0)
continue; continue;
@@ -319,14 +317,15 @@ public sealed partial class MediaScan
currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed); currentSpeed = sectorSpeedStart * blockSize / (1048576 * elapsed);
ScanSpeed?.Invoke(i, currentSpeed * 1024); ScanSpeed?.Invoke(i, currentSpeed * 1024);
sectorSpeedStart = 0; sectorSpeedStart = 0;
timeSpeedStart = DateTime.UtcNow; _speedStopwatch.Restart();
} }
end = DateTime.UtcNow; _speedStopwatch.Stop();
_scanStopwatch.Stop();
EndProgress?.Invoke(); EndProgress?.Invoke();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(_dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(_dev, results.Blocks, blockSize, _scanStopwatch.Elapsed.TotalSeconds, currentSpeed * 1024,
blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), _devicePath); blockSize * (double)(results.Blocks + 1) / 1024 / (results.ProcessingTime / 1000), _devicePath);
InitProgress?.Invoke(); InitProgress?.Invoke();
@@ -357,7 +356,7 @@ public sealed partial class MediaScan
EndProgress?.Invoke(); EndProgress?.Invoke();
results.ProcessingTime /= 1000; results.ProcessingTime /= 1000;
results.TotalTime = (end - start).TotalSeconds; results.TotalTime = _scanStopwatch.Elapsed.TotalSeconds;
results.AvgSpeed = blockSize * (double)(results.Blocks + 1) / 1048576 / results.ProcessingTime; results.AvgSpeed = blockSize * (double)(results.Blocks + 1) / 1048576 / results.ProcessingTime;
results.SeekTimes = seekTimes; results.SeekTimes = seekTimes;

View File

@@ -31,6 +31,7 @@
// ****************************************************************************/ // ****************************************************************************/
using System; using System;
using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.IO; using System.IO;
using System.Text; using System.Text;
@@ -46,7 +47,7 @@ sealed class IbgLog
readonly string _ibgMediaType; readonly string _ibgMediaType;
readonly StringBuilder _ibgSb; readonly StringBuilder _ibgSb;
readonly string _logFile; readonly string _logFile;
DateTime _ibgDatePoint; readonly Stopwatch _ibgStopwatch;
ulong _ibgIntSector; ulong _ibgIntSector;
double _ibgIntSpeed; double _ibgIntSpeed;
double _ibgMaxSpeed; double _ibgMaxSpeed;
@@ -65,7 +66,7 @@ sealed class IbgLog
_logFile = outputFile; _logFile = outputFile;
_ibgSb = new StringBuilder(); _ibgSb = new StringBuilder();
_ibgDatePoint = DateTime.Now; _ibgStopwatch = new Stopwatch();
_ibgCulture = new CultureInfo("en-US"); _ibgCulture = new CultureInfo("en-US");
_ibgStartSet = false; _ibgStartSet = false;
_ibgMaxSpeed = 0; _ibgMaxSpeed = 0;
@@ -73,6 +74,8 @@ sealed class IbgLog
_ibgSnaps = 0; _ibgSnaps = 0;
_ibgIntSector = 0; _ibgIntSector = 0;
_ibgStopwatch.Start();
switch(currentProfile) switch(currentProfile)
{ {
case 0x0001: case 0x0001:
@@ -240,7 +243,7 @@ sealed class IbgLog
return; return;
_ibgIntSpeed += currentSpeed; _ibgIntSpeed += currentSpeed;
_ibgSampleRate += (int)Math.Floor((DateTime.Now - _ibgDatePoint).TotalMilliseconds); _ibgSampleRate += (int)Math.Floor(_ibgStopwatch.Elapsed.TotalMilliseconds);
_ibgSnaps++; _ibgSnaps++;
if(_ibgSampleRate < 100) if(_ibgSampleRate < 100)
@@ -259,7 +262,7 @@ sealed class IbgLog
if(_ibgIntSpeed / _ibgSnaps / _ibgDivider > _ibgMaxSpeed) if(_ibgIntSpeed / _ibgSnaps / _ibgDivider > _ibgMaxSpeed)
_ibgMaxSpeed = _ibgIntSpeed / _ibgDivider; _ibgMaxSpeed = _ibgIntSpeed / _ibgDivider;
_ibgDatePoint = DateTime.Now; _ibgStopwatch.Restart();
_ibgIntSpeed = 0; _ibgIntSpeed = 0;
_ibgSampleRate = 0; _ibgSampleRate = 0;
_ibgSnaps = 0; _ibgSnaps = 0;
@@ -280,6 +283,8 @@ sealed class IbgLog
if(_logFile == null) if(_logFile == null)
return; return;
_ibgStopwatch.Stop();
var ibgFs = new FileStream(_logFile, FileMode.Create); var ibgFs = new FileStream(_logFile, FileMode.Create);
var ibgHeader = new StringBuilder(); var ibgHeader = new StringBuilder();
string ibgBusType; string ibgBusType;

View File

@@ -32,6 +32,7 @@
// ****************************************************************************/ // ****************************************************************************/
using System; using System;
using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Aaru.CommonTypes.Interop; using Aaru.CommonTypes.Interop;
@@ -84,9 +85,10 @@ partial class Device
Marshal.Copy(cdb, 0, ioHdr.cmdp, cdb.Length); Marshal.Copy(cdb, 0, ioHdr.cmdp, cdb.Length);
Marshal.Copy(senseBuffer, 0, ioHdr.sbp, senseBuffer.Length); Marshal.Copy(senseBuffer, 0, ioHdr.sbp, senseBuffer.Length);
DateTime start = DateTime.UtcNow; var cmdStopWatch = new Stopwatch();
int error = Extern.ioctlSg(_fileDescriptor, LinuxIoctl.SgIo, ref ioHdr); cmdStopWatch.Start();
DateTime end = DateTime.UtcNow; int error = Extern.ioctlSg(_fileDescriptor, LinuxIoctl.SgIo, ref ioHdr);
cmdStopWatch.Stop();
if(error < 0) if(error < 0)
error = Marshal.GetLastWin32Error(); error = Marshal.GetLastWin32Error();
@@ -97,7 +99,7 @@ partial class Device
sense |= (ioHdr.info & SgInfo.OkMask) != SgInfo.Ok; sense |= (ioHdr.info & SgInfo.OkMask) != SgInfo.Ok;
duration = ioHdr.duration > 0 ? ioHdr.duration : (end - start).TotalMilliseconds; duration = ioHdr.duration > 0 ? ioHdr.duration : cmdStopWatch.Elapsed.TotalMilliseconds;
Marshal.FreeHGlobal(ioHdr.dxferp); Marshal.FreeHGlobal(ioHdr.dxferp);
Marshal.FreeHGlobal(ioHdr.cmdp); Marshal.FreeHGlobal(ioHdr.cmdp);
@@ -366,57 +368,56 @@ partial class Device
if(timeout == 0) if(timeout == 0)
timeout = Timeout > 0 ? Timeout : 15; timeout = Timeout > 0 ? Timeout : 15;
DateTime start; var cmdStopwatch = new Stopwatch();
DateTime end;
switch(command) switch(command)
{ {
case MmcCommands.SendCid when _cachedCid != null: case MmcCommands.SendCid when _cachedCid != null:
{ {
start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedCid.Length]; buffer = new byte[_cachedCid.Length];
Array.Copy(_cachedCid, buffer, buffer.Length); Array.Copy(_cachedCid, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }
case MmcCommands.SendCsd when _cachedCid != null: case MmcCommands.SendCsd when _cachedCid != null:
{ {
start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedCsd.Length]; buffer = new byte[_cachedCsd.Length];
Array.Copy(_cachedCsd, buffer, buffer.Length); Array.Copy(_cachedCsd, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }
case (MmcCommands)SecureDigitalCommands.SendScr when _cachedScr != null: case (MmcCommands)SecureDigitalCommands.SendScr when _cachedScr != null:
{ {
start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedScr.Length]; buffer = new byte[_cachedScr.Length];
Array.Copy(_cachedScr, buffer, buffer.Length); Array.Copy(_cachedScr, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }
case (MmcCommands)SecureDigitalCommands.SendOperatingCondition when _cachedOcr != null: case (MmcCommands)SecureDigitalCommands.SendOperatingCondition when _cachedOcr != null:
case MmcCommands.SendOpCond when _cachedOcr != null: case MmcCommands.SendOpCond when _cachedOcr != null:
{ {
start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedOcr.Length]; buffer = new byte[_cachedOcr.Length];
Array.Copy(_cachedOcr, buffer, buffer.Length); Array.Copy(_cachedOcr, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }
@@ -451,9 +452,10 @@ partial class Device
Marshal.Copy(buffer, 0, bufPtr, buffer.Length); Marshal.Copy(buffer, 0, bufPtr, buffer.Length);
start = DateTime.UtcNow; var stopWatch = new Stopwatch();
stopWatch.Restart();
int error = Extern.ioctlMmc(_fileDescriptor, LinuxIoctl.MmcIocCmd, ref ioCmd); int error = Extern.ioctlMmc(_fileDescriptor, LinuxIoctl.MmcIocCmd, ref ioCmd);
end = DateTime.UtcNow; stopWatch.Stop();
sense |= error < 0; sense |= error < 0;
@@ -463,7 +465,7 @@ partial class Device
Marshal.Copy(bufPtr, buffer, 0, buffer.Length); Marshal.Copy(bufPtr, buffer, 0, buffer.Length);
response = ioCmd.response; response = ioCmd.response;
duration = (end - start).TotalMilliseconds; duration = stopWatch.Elapsed.TotalMilliseconds;
Marshal.FreeHGlobal(bufPtr); Marshal.FreeHGlobal(bufPtr);
@@ -535,16 +537,17 @@ partial class Device
Marshal.Copy(ioMultiCmd, 0, ioMultiCmdPtr, ioMultiCmd.Length); Marshal.Copy(ioMultiCmd, 0, ioMultiCmdPtr, ioMultiCmd.Length);
// Send command // Send command
DateTime start = DateTime.UtcNow; var cmdStopwatch = new Stopwatch();
int error = Extern.ioctlMmcMulti(_fileDescriptor, LinuxIoctl.MmcIocMultiCmd, ioMultiCmdPtr); cmdStopwatch.Start();
DateTime end = DateTime.UtcNow; int error = Extern.ioctlMmcMulti(_fileDescriptor, LinuxIoctl.MmcIocMultiCmd, ioMultiCmdPtr);
cmdStopwatch.Stop();
sense |= error < 0; sense |= error < 0;
if(error < 0) if(error < 0)
error = Marshal.GetLastWin32Error(); error = Marshal.GetLastWin32Error();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
off = sizeof(ulong); off = sizeof(ulong);
@@ -670,15 +673,15 @@ partial class Device
{ {
buffer = new byte[length]; buffer = new byte[length];
DateTime start = DateTime.Now; var cmdStopwatch = new Stopwatch();
cmdStopwatch.Start();
long sense = Extern.lseek(_fileDescriptor, offset, SeekWhence.Begin); long sense = Extern.lseek(_fileDescriptor, offset, SeekWhence.Begin);
DateTime end = DateTime.Now;
if(sense < 0) if(sense < 0)
{ {
duration = (end - start).TotalMilliseconds; cmdStopwatch.Stop();
duration = cmdStopwatch.Elapsed.TotalMilliseconds;
Error = true; Error = true;
LastError = Marshal.GetLastWin32Error(); LastError = Marshal.GetLastWin32Error();
@@ -689,8 +692,8 @@ partial class Device
sense = DetectOS.Is64Bit ? Extern.read64(_fileDescriptor, buffer, length) sense = DetectOS.Is64Bit ? Extern.read64(_fileDescriptor, buffer, length)
: Extern.read(_fileDescriptor, buffer, (int)length); : Extern.read(_fileDescriptor, buffer, (int)length);
end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
int errno = Marshal.GetLastWin32Error(); int errno = Marshal.GetLastWin32Error();

View File

@@ -31,6 +31,7 @@
// ****************************************************************************/ // ****************************************************************************/
using System; using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using Aaru.Decoders.ATA; using Aaru.Decoders.ATA;
@@ -98,54 +99,56 @@ public partial class Device
if(timeout == 0) if(timeout == 0)
timeout = Timeout > 0 ? Timeout : 15; timeout = Timeout > 0 ? Timeout : 15;
var cmdStopwatch = new Stopwatch();
switch(command) switch(command)
{ {
case MmcCommands.SendCid when _cachedCid != null: case MmcCommands.SendCid when _cachedCid != null:
{ {
DateTime start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedCid.Length]; buffer = new byte[_cachedCid.Length];
Array.Copy(_cachedCid, buffer, buffer.Length); Array.Copy(_cachedCid, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
DateTime end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }
case MmcCommands.SendCsd when _cachedCid != null: case MmcCommands.SendCsd when _cachedCid != null:
{ {
DateTime start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedCsd.Length]; buffer = new byte[_cachedCsd.Length];
Array.Copy(_cachedCsd, buffer, buffer.Length); Array.Copy(_cachedCsd, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
DateTime end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }
case (MmcCommands)SecureDigitalCommands.SendScr when _cachedScr != null: case (MmcCommands)SecureDigitalCommands.SendScr when _cachedScr != null:
{ {
DateTime start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedScr.Length]; buffer = new byte[_cachedScr.Length];
Array.Copy(_cachedScr, buffer, buffer.Length); Array.Copy(_cachedScr, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
DateTime end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }
case (MmcCommands)SecureDigitalCommands.SendOperatingCondition when _cachedOcr != null: case (MmcCommands)SecureDigitalCommands.SendOperatingCondition when _cachedOcr != null:
case MmcCommands.SendOpCond when _cachedOcr != null: case MmcCommands.SendOpCond when _cachedOcr != null:
{ {
DateTime start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedOcr.Length]; buffer = new byte[_cachedOcr.Length];
Array.Copy(_cachedOcr, buffer, buffer.Length); Array.Copy(_cachedOcr, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
DateTime end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }

View File

@@ -32,6 +32,7 @@
// ****************************************************************************/ // ****************************************************************************/
using System; using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Aaru.Decoders.ATA; using Aaru.Decoders.ATA;
@@ -88,13 +89,14 @@ partial class Device
Marshal.Copy(buffer, 0, sptdSb.sptd.DataBuffer, buffer.Length); Marshal.Copy(buffer, 0, sptdSb.sptd.DataBuffer, buffer.Length);
DateTime start = DateTime.Now; var cmdStopwatch = new Stopwatch();
cmdStopwatch.Start();
bool hasError = !Extern.DeviceIoControlScsi(_fileHandle, WindowsIoctl.IoctlScsiPassThroughDirect, ref sptdSb, bool hasError = !Extern.DeviceIoControlScsi(_fileHandle, WindowsIoctl.IoctlScsiPassThroughDirect, ref sptdSb,
(uint)Marshal.SizeOf(sptdSb), ref sptdSb, (uint)Marshal.SizeOf(sptdSb), ref sptdSb,
(uint)Marshal.SizeOf(sptdSb), ref k, IntPtr.Zero); (uint)Marshal.SizeOf(sptdSb), ref k, IntPtr.Zero);
DateTime end = DateTime.Now; cmdStopwatch.Stop();
if(hasError) if(hasError)
error = Marshal.GetLastWin32Error(); error = Marshal.GetLastWin32Error();
@@ -106,7 +108,7 @@ partial class Device
senseBuffer = new byte[64]; senseBuffer = new byte[64];
Array.Copy(sptdSb.SenseBuf, senseBuffer, 32); Array.Copy(sptdSb.SenseBuf, senseBuffer, 32);
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
Marshal.FreeHGlobal(sptdSb.sptd.DataBuffer); Marshal.FreeHGlobal(sptdSb.sptd.DataBuffer);
@@ -183,20 +185,21 @@ partial class Device
Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length); Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length);
DateTime start = DateTime.Now; var cmdStopwatch = new Stopwatch();
cmdStopwatch.Start();
sense = !Extern.DeviceIoControlAta(_fileHandle, WindowsIoctl.IoctlAtaPassThroughDirect, ref aptd, sense = !Extern.DeviceIoControlAta(_fileHandle, WindowsIoctl.IoctlAtaPassThroughDirect, ref aptd,
(uint)Marshal.SizeOf(aptd), ref aptd, (uint)Marshal.SizeOf(aptd), ref k, (uint)Marshal.SizeOf(aptd), ref aptd, (uint)Marshal.SizeOf(aptd), ref k,
IntPtr.Zero); IntPtr.Zero);
DateTime end = DateTime.Now; cmdStopwatch.Stop();
if(sense) if(sense)
error = Marshal.GetLastWin32Error(); error = Marshal.GetLastWin32Error();
Marshal.Copy(aptd.DataBuffer, buffer, 0, buffer.Length); Marshal.Copy(aptd.DataBuffer, buffer, 0, buffer.Length);
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
errorRegisters.CylinderHigh = aptd.CurrentTaskFile.CylinderHigh; errorRegisters.CylinderHigh = aptd.CurrentTaskFile.CylinderHigh;
errorRegisters.CylinderLow = aptd.CurrentTaskFile.CylinderLow; errorRegisters.CylinderLow = aptd.CurrentTaskFile.CylinderLow;
@@ -283,20 +286,21 @@ partial class Device
Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length); Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length);
DateTime start = DateTime.Now; var cmdStopwatch = new Stopwatch();
cmdStopwatch.Start();
sense = !Extern.DeviceIoControlAta(_fileHandle, WindowsIoctl.IoctlAtaPassThroughDirect, ref aptd, sense = !Extern.DeviceIoControlAta(_fileHandle, WindowsIoctl.IoctlAtaPassThroughDirect, ref aptd,
(uint)Marshal.SizeOf(aptd), ref aptd, (uint)Marshal.SizeOf(aptd), ref k, (uint)Marshal.SizeOf(aptd), ref aptd, (uint)Marshal.SizeOf(aptd), ref k,
IntPtr.Zero); IntPtr.Zero);
DateTime end = DateTime.Now; cmdStopwatch.Stop();
if(sense) if(sense)
error = Marshal.GetLastWin32Error(); error = Marshal.GetLastWin32Error();
Marshal.Copy(aptd.DataBuffer, buffer, 0, buffer.Length); Marshal.Copy(aptd.DataBuffer, buffer, 0, buffer.Length);
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
errorRegisters.LbaHigh = aptd.CurrentTaskFile.CylinderHigh; errorRegisters.LbaHigh = aptd.CurrentTaskFile.CylinderHigh;
errorRegisters.LbaMid = aptd.CurrentTaskFile.CylinderLow; errorRegisters.LbaMid = aptd.CurrentTaskFile.CylinderLow;
@@ -392,20 +396,21 @@ partial class Device
Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length); Marshal.Copy(buffer, 0, aptd.DataBuffer, buffer.Length);
DateTime start = DateTime.Now; var cmdStopwatch = new Stopwatch();
cmdStopwatch.Start();
sense = !Extern.DeviceIoControlAta(_fileHandle, WindowsIoctl.IoctlAtaPassThroughDirect, ref aptd, sense = !Extern.DeviceIoControlAta(_fileHandle, WindowsIoctl.IoctlAtaPassThroughDirect, ref aptd,
(uint)Marshal.SizeOf(aptd), ref aptd, (uint)Marshal.SizeOf(aptd), ref k, (uint)Marshal.SizeOf(aptd), ref aptd, (uint)Marshal.SizeOf(aptd), ref k,
IntPtr.Zero); IntPtr.Zero);
DateTime end = DateTime.Now; cmdStopwatch.Stop();
if(sense) if(sense)
error = Marshal.GetLastWin32Error(); error = Marshal.GetLastWin32Error();
Marshal.Copy(aptd.DataBuffer, buffer, 0, buffer.Length); Marshal.Copy(aptd.DataBuffer, buffer, 0, buffer.Length);
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
errorRegisters.SectorCount = (ushort)((aptd.PreviousTaskFile.SectorCount << 8) + errorRegisters.SectorCount = (ushort)((aptd.PreviousTaskFile.SectorCount << 8) +
aptd.CurrentTaskFile.SectorCount); aptd.CurrentTaskFile.SectorCount);
@@ -447,57 +452,56 @@ partial class Device
uint argument, uint blockSize, uint blocks, ref byte[] buffer, uint argument, uint blockSize, uint blocks, ref byte[] buffer,
out uint[] response, out double duration, out bool sense, uint timeout = 15) out uint[] response, out double duration, out bool sense, uint timeout = 15)
{ {
DateTime start; var cmdStopwatch = new Stopwatch();
DateTime end;
switch(command) switch(command)
{ {
case MmcCommands.SendCid when _cachedCid != null: case MmcCommands.SendCid when _cachedCid != null:
{ {
start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedCid.Length]; buffer = new byte[_cachedCid.Length];
Array.Copy(_cachedCid, buffer, buffer.Length); Array.Copy(_cachedCid, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }
case MmcCommands.SendCsd when _cachedCid != null: case MmcCommands.SendCsd when _cachedCid != null:
{ {
start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedCsd.Length]; buffer = new byte[_cachedCsd.Length];
Array.Copy(_cachedCsd, buffer, buffer.Length); Array.Copy(_cachedCsd, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }
case (MmcCommands)SecureDigitalCommands.SendScr when _cachedScr != null: case (MmcCommands)SecureDigitalCommands.SendScr when _cachedScr != null:
{ {
start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedScr.Length]; buffer = new byte[_cachedScr.Length];
Array.Copy(_cachedScr, buffer, buffer.Length); Array.Copy(_cachedScr, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }
case (MmcCommands)SecureDigitalCommands.SendOperatingCondition when _cachedOcr != null: case (MmcCommands)SecureDigitalCommands.SendOperatingCondition when _cachedOcr != null:
case MmcCommands.SendOpCond when _cachedOcr != null: case MmcCommands.SendOpCond when _cachedOcr != null:
{ {
start = DateTime.Now; cmdStopwatch.Restart();
buffer = new byte[_cachedOcr.Length]; buffer = new byte[_cachedOcr.Length];
Array.Copy(_cachedOcr, buffer, buffer.Length); Array.Copy(_cachedOcr, buffer, buffer.Length);
response = new uint[4]; response = new uint[4];
sense = false; sense = false;
end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return 0; return 0;
} }
@@ -559,12 +563,12 @@ partial class Device
Marshal.FreeHGlobal(hBuf); Marshal.FreeHGlobal(hBuf);
int error = 0; int error = 0;
start = DateTime.Now; cmdStopwatch.Restart();
sense = !Extern.DeviceIoControl(_fileHandle, WindowsIoctl.IoctlSffdiskDeviceCommand, commandB, sense = !Extern.DeviceIoControl(_fileHandle, WindowsIoctl.IoctlSffdiskDeviceCommand, commandB,
(uint)commandB.Length, commandB, (uint)commandB.Length, out _, IntPtr.Zero); (uint)commandB.Length, commandB, (uint)commandB.Length, out _, IntPtr.Zero);
end = DateTime.Now; cmdStopwatch.Stop();
if(sense) if(sense)
error = Marshal.GetLastWin32Error(); error = Marshal.GetLastWin32Error();
@@ -573,7 +577,7 @@ partial class Device
Buffer.BlockCopy(commandB, commandB.Length - buffer.Length, buffer, 0, buffer.Length); Buffer.BlockCopy(commandB, commandB.Length - buffer.Length, buffer, 0, buffer.Length);
response = new uint[4]; response = new uint[4];
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
return error; return error;
} }
@@ -644,15 +648,17 @@ partial class Device
{ {
buffer = new byte[length]; buffer = new byte[length];
DateTime start = DateTime.Now; var cmdStopwatch = new Stopwatch();
cmdStopwatch.Start();
bool sense = !Extern.SetFilePointerEx(_fileHandle, offset, out _, MoveMethod.Begin); bool sense = !Extern.SetFilePointerEx(_fileHandle, offset, out _, MoveMethod.Begin);
DateTime end = DateTime.Now; cmdStopwatch.Stop();
if(sense) if(sense)
{ {
duration = (end - start).TotalMilliseconds; cmdStopwatch.Stop();
duration = cmdStopwatch.Elapsed.TotalMilliseconds;
LastError = Marshal.GetLastWin32Error(); LastError = Marshal.GetLastWin32Error();
Error = true; Error = true;
@@ -662,8 +668,8 @@ partial class Device
sense = !Extern.ReadFile(_fileHandle, buffer, length, out _, IntPtr.Zero); sense = !Extern.ReadFile(_fileHandle, buffer, length, out _, IntPtr.Zero);
end = DateTime.Now; cmdStopwatch.Stop();
duration = (end - start).TotalMilliseconds; duration = cmdStopwatch.Elapsed.TotalMilliseconds;
if(sense) if(sense)
{ {

View File

@@ -30,9 +30,9 @@
// Copyright © 2011-2023 Natalia Portillo // Copyright © 2011-2023 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Reactive; using System.Reactive;
using System.Threading; using System.Threading;
@@ -421,11 +421,10 @@ public sealed class ImageVerifyViewModel : ViewModelBase
Progress2Indeterminate = true; Progress2Indeterminate = true;
}); });
DateTime startCheck = DateTime.UtcNow; var chkStopwatch = new Stopwatch();
chkStopwatch.Start();
bool? discCheckStatus = verifiableImage.VerifyMediaImage(); bool? discCheckStatus = verifiableImage.VerifyMediaImage();
DateTime endCheck = DateTime.UtcNow; chkStopwatch.Stop();
TimeSpan checkTime = endCheck - startCheck;
await Dispatcher.UIThread.InvokeAsync(() => await Dispatcher.UIThread.InvokeAsync(() =>
{ {
@@ -440,16 +439,15 @@ public sealed class ImageVerifyViewModel : ViewModelBase
}); });
AaruConsole.VerboseWriteLine(UI.Checking_disc_image_checksums_took_0, AaruConsole.VerboseWriteLine(UI.Checking_disc_image_checksums_took_0,
checkTime.Humanize(minUnit: TimeUnit.Second)); chkStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
} }
} }
if(VerifySectorsChecked) if(VerifySectorsChecked)
{ {
DateTime startCheck = DateTime.Now; var chkStopwatch = new Stopwatch();
DateTime endCheck = startCheck; List<ulong> failingLbas = new();
List<ulong> failingLbas = new(); List<ulong> unknownLbas = new();
List<ulong> unknownLbas = new();
await Dispatcher.UIThread.InvokeAsync(() => await Dispatcher.UIThread.InvokeAsync(() =>
{ {
@@ -463,7 +461,7 @@ public sealed class ImageVerifyViewModel : ViewModelBase
{ {
ulong currentSectorAll = 0; ulong currentSectorAll = 0;
startCheck = DateTime.UtcNow; chkStopwatch.Restart();
foreach(Track currentTrack in inputOptical.Tracks) foreach(Track currentTrack in inputOptical.Tracks)
{ {
@@ -531,14 +529,14 @@ public sealed class ImageVerifyViewModel : ViewModelBase
} }
} }
endCheck = DateTime.UtcNow; chkStopwatch.Stop();
} }
else if(verifiableSectorsImage is not null) else if(verifiableSectorsImage is not null)
{ {
ulong remainingSectors = _inputFormat.Info.Sectors; ulong remainingSectors = _inputFormat.Info.Sectors;
ulong currentSector = 0; ulong currentSector = 0;
startCheck = DateTime.UtcNow; chkStopwatch.Restart();
while(remainingSectors > 0) while(remainingSectors > 0)
{ {
@@ -588,13 +586,11 @@ public sealed class ImageVerifyViewModel : ViewModelBase
} }
} }
endCheck = DateTime.UtcNow; chkStopwatch.Stop();
} }
TimeSpan checkTime = endCheck - startCheck;
AaruConsole.VerboseWriteLine(UI.Checking_sector_checksums_took_0, AaruConsole.VerboseWriteLine(UI.Checking_sector_checksums_took_0,
checkTime.Humanize(minUnit: TimeUnit.Second)); chkStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
await Dispatcher.UIThread.InvokeAsync(() => await Dispatcher.UIThread.InvokeAsync(() =>
{ {

View File

@@ -31,6 +31,7 @@
// ****************************************************************************/ // ****************************************************************************/
using System; using System;
using System.Diagnostics;
using Aaru.Console; using Aaru.Console;
namespace Aaru.DiscImages; namespace Aaru.DiscImages;
@@ -51,7 +52,8 @@ public sealed partial class AaruFormat
int[] v = new int[interleaved.Length / 8]; int[] v = new int[interleaved.Length / 8];
int[] w = new int[interleaved.Length / 8]; int[] w = new int[interleaved.Length / 8];
DateTime start = DateTime.UtcNow; var stopwatch = new Stopwatch();
stopwatch.Start();
for(int i = 0; i < interleaved.Length; i += 8) for(int i = 0; i < interleaved.Length; i += 8)
{ {
@@ -128,11 +130,11 @@ public sealed partial class AaruFormat
w[i / 8] += interleaved[i + 7] & 0x01; w[i / 8] += interleaved[i + 7] & 0x01;
} }
DateTime end = DateTime.UtcNow; stopwatch.Stop();
TimeSpan deinterleave = end - start; TimeSpan deinterleave = stopwatch.Elapsed;
byte[] sequential = new byte[interleaved.Length]; byte[] sequential = new byte[interleaved.Length];
start = DateTime.UtcNow; stopwatch.Restart();
int qStart = p.Length * 1; int qStart = p.Length * 1;
int rStart = p.Length * 2; int rStart = p.Length * 2;
@@ -154,8 +156,8 @@ public sealed partial class AaruFormat
sequential[wStart + i] = (byte)w[i]; sequential[wStart + i] = (byte)w[i];
} }
end = DateTime.UtcNow; stopwatch.Stop();
TimeSpan sequentialize = end - start; TimeSpan sequentialize = stopwatch.Elapsed;
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_ms_to_deinterleave_subchannel, AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_ms_to_deinterleave_subchannel,
deinterleave.TotalMilliseconds); deinterleave.TotalMilliseconds);
@@ -191,7 +193,8 @@ public sealed partial class AaruFormat
int vStart = p.Length * 6; int vStart = p.Length * 6;
int wStart = p.Length * 7; int wStart = p.Length * 7;
DateTime start = DateTime.UtcNow; var stopwatch = new Stopwatch();
stopwatch.Start();
for(int i = 0; i < p.Length; i++) for(int i = 0; i < p.Length; i++)
{ {
@@ -205,11 +208,11 @@ public sealed partial class AaruFormat
w[i] = sequential[wStart + i]; w[i] = sequential[wStart + i];
} }
DateTime end = DateTime.UtcNow; stopwatch.Stop();
TimeSpan desequentialize = end - start; TimeSpan desequentialize = stopwatch.Elapsed;
byte[] interleaved = new byte[sequential.Length]; byte[] interleaved = new byte[sequential.Length];
start = DateTime.UtcNow; stopwatch.Restart();
for(int i = 0; i < interleaved.Length; i += 8) for(int i = 0; i < interleaved.Length; i += 8)
{ {
@@ -286,8 +289,8 @@ public sealed partial class AaruFormat
interleaved[i + 7] += (byte)((w[i / 8] & 0x01) == 0x01 ? 0x01 : 0); interleaved[i + 7] += (byte)((w[i / 8] & 0x01) == 0x01 ? 0x01 : 0);
} }
end = DateTime.UtcNow; stopwatch.Stop();
TimeSpan interleave = end - start; TimeSpan interleave = stopwatch.Elapsed;
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_ms_to_desequentialize_subchannel, AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_ms_to_desequentialize_subchannel,
desequentialize.TotalMilliseconds); desequentialize.TotalMilliseconds);

View File

@@ -33,6 +33,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -240,9 +241,10 @@ public sealed partial class AaruFormat
break; break;
} }
DateTime startDecompress = DateTime.Now; var decompressStopwatch = new Stopwatch();
byte[] compressedTag = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; decompressStopwatch.Start();
byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; byte[] compressedTag = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH];
byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH];
_imageStream.EnsureRead(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); _imageStream.EnsureRead(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH);
_imageStream.EnsureRead(compressedTag, 0, compressedTag.Length); _imageStream.EnsureRead(compressedTag, 0, compressedTag.Length);
data = new byte[blockHeader.length]; data = new byte[blockHeader.length];
@@ -261,11 +263,11 @@ public sealed partial class AaruFormat
if(blockHeader.compression == CompressionType.LzmaClauniaSubchannelTransform) if(blockHeader.compression == CompressionType.LzmaClauniaSubchannelTransform)
data = ClauniaSubchannelUntransform(data); data = ClauniaSubchannelUntransform(data);
DateTime endDecompress = DateTime.Now; decompressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_decompress_block, Localization.Took_0_seconds_to_decompress_block,
(endDecompress - startDecompress).TotalSeconds); decompressStopwatch.Elapsed.TotalSeconds);
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Memory_snapshot_0_bytes, AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Memory_snapshot_0_bytes,
GC.GetTotalMemory(false)); GC.GetTotalMemory(false));
@@ -483,7 +485,8 @@ public sealed partial class AaruFormat
{ {
case CompressionType.Lzma: case CompressionType.Lzma:
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Decompressing_DDT); AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Decompressing_DDT);
DateTime ddtStart = DateTime.UtcNow; var ddtStopwatch = new Stopwatch();
ddtStopwatch.Start();
byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH];
byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH];
_imageStream.EnsureRead(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); _imageStream.EnsureRead(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH);
@@ -504,12 +507,12 @@ public sealed partial class AaruFormat
} }
_userDataDdt = MemoryMarshal.Cast<byte, ulong>(decompressedDdt).ToArray(); _userDataDdt = MemoryMarshal.Cast<byte, ulong>(decompressedDdt).ToArray();
DateTime ddtEnd = DateTime.UtcNow; ddtStopwatch.Stop();
_inMemoryDdt = true; _inMemoryDdt = true;
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_decompress_DDT, Localization.Took_0_seconds_to_decompress_DDT,
(ddtEnd - ddtStart).TotalSeconds); ddtStopwatch.Elapsed.TotalSeconds);
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Memory_snapshot_0_bytes, Localization.Memory_snapshot_0_bytes,
@@ -550,7 +553,8 @@ public sealed partial class AaruFormat
{ {
case CompressionType.Lzma: case CompressionType.Lzma:
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Decompressing_DDT); AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Decompressing_DDT);
DateTime ddtStart = DateTime.UtcNow; var ddtStopwatch = new Stopwatch();
ddtStopwatch.Start();
byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH];
byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH];
_imageStream.EnsureRead(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); _imageStream.EnsureRead(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH);
@@ -559,7 +563,7 @@ public sealed partial class AaruFormat
ulong decompressedLength = ulong decompressedLength =
(ulong)LZMA.DecodeBuffer(compressedDdt, decompressedDdt, lzmaProperties); (ulong)LZMA.DecodeBuffer(compressedDdt, decompressedDdt, lzmaProperties);
DateTime ddtEnd = DateTime.UtcNow; ddtStopwatch.Stop();
if(decompressedLength != ddtHeader.length) if(decompressedLength != ddtHeader.length)
{ {
@@ -573,7 +577,7 @@ public sealed partial class AaruFormat
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_decompress_DDT, Localization.Took_0_seconds_to_decompress_DDT,
(ddtEnd - ddtStart).TotalSeconds); ddtStopwatch.Elapsed.TotalSeconds);
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Memory_snapshot_0_bytes, Localization.Memory_snapshot_0_bytes,

View File

@@ -33,6 +33,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -412,7 +413,8 @@ public sealed partial class AaruFormat
break; break;
} }
DateTime startDecompress = DateTime.Now; var decompressStopwatch = new Stopwatch();
decompressStopwatch.Restart();
byte[] compressedTag = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] compressedTag = new byte[blockHeader.cmpLength - LZMA_PROPERTIES_LENGTH];
byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH]; byte[] lzmaProperties = new byte[LZMA_PROPERTIES_LENGTH];
_imageStream.EnsureRead(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH); _imageStream.EnsureRead(lzmaProperties, 0, LZMA_PROPERTIES_LENGTH);
@@ -433,11 +435,11 @@ public sealed partial class AaruFormat
if(blockHeader.compression == CompressionType.LzmaClauniaSubchannelTransform) if(blockHeader.compression == CompressionType.LzmaClauniaSubchannelTransform)
data = ClauniaSubchannelUntransform(data); data = ClauniaSubchannelUntransform(data);
DateTime endDecompress = DateTime.Now; decompressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_decompress_block, Localization.Took_0_seconds_to_decompress_block,
(endDecompress - startDecompress).TotalSeconds); decompressStopwatch.Elapsed.TotalSeconds);
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Memory_snapshot_0_bytes, AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Memory_snapshot_0_bytes,
GC.GetTotalMemory(false)); GC.GetTotalMemory(false));
@@ -629,7 +631,8 @@ public sealed partial class AaruFormat
case CompressionType.Lzma: case CompressionType.Lzma:
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Decompressing_DDT); AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Decompressing_DDT);
DateTime ddtStart = DateTime.UtcNow; var ddtStopwatch = new Stopwatch();
ddtStopwatch.Start();
byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH];
@@ -652,12 +655,12 @@ public sealed partial class AaruFormat
} }
_userDataDdt = MemoryMarshal.Cast<byte, ulong>(decompressedDdt).ToArray(); _userDataDdt = MemoryMarshal.Cast<byte, ulong>(decompressedDdt).ToArray();
DateTime ddtEnd = DateTime.UtcNow; ddtStopwatch.Stop();
_inMemoryDdt = true; _inMemoryDdt = true;
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_decompress_DDT, Localization.Took_0_seconds_to_decompress_DDT,
(ddtEnd - ddtStart).TotalSeconds); ddtStopwatch.Elapsed.TotalSeconds);
break; break;
case CompressionType.None: case CompressionType.None:
@@ -711,7 +714,8 @@ public sealed partial class AaruFormat
case CompressionType.Lzma: case CompressionType.Lzma:
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Decompressing_DDT); AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Decompressing_DDT);
DateTime ddtStart = DateTime.UtcNow; var ddtStopwatch = new Stopwatch();
ddtStopwatch.Start();
byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH]; byte[] compressedDdt = new byte[ddtHeader.cmpLength - LZMA_PROPERTIES_LENGTH];
@@ -732,11 +736,11 @@ public sealed partial class AaruFormat
return false; return false;
} }
DateTime ddtEnd = DateTime.UtcNow; ddtStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_decompress_DDT, Localization.Took_0_seconds_to_decompress_DDT,
(ddtEnd - ddtStart).TotalSeconds); ddtStopwatch.Elapsed.TotalSeconds);
break; break;
case CompressionType.None: case CompressionType.None:
@@ -3262,8 +3266,7 @@ public sealed partial class AaruFormat
switch(_imageInfo.MetadataMediaType) switch(_imageInfo.MetadataMediaType)
{ {
case MetadataMediaType.OpticalDisc when Tracks is { Count: > 0 }: case MetadataMediaType.OpticalDisc when Tracks is { Count: > 0 }:
DateTime startCompress; var compressStopwatch = new Stopwatch();
DateTime endCompress;
// Old format // Old format
if(_sectorPrefix != null && if(_sectorPrefix != null &&
@@ -3302,7 +3305,7 @@ public sealed partial class AaruFormat
} }
else else
{ {
startCompress = DateTime.Now; compressStopwatch.Restart();
byte[] cmpBuffer = new byte[_sectorPrefix.Length + 262144]; byte[] cmpBuffer = new byte[_sectorPrefix.Length + 262144];
@@ -3340,10 +3343,10 @@ public sealed partial class AaruFormat
prefixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); prefixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0);
prefixBlock.compression = _compressionAlgorithm; prefixBlock.compression = _compressionAlgorithm;
endCompress = DateTime.Now; compressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_seconds_to_compress_prefix, AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_seconds_to_compress_prefix,
(endCompress - startCompress).TotalSeconds); compressStopwatch.Elapsed.TotalSeconds);
} }
_structureBytes = new byte[Marshal.SizeOf<BlockHeader>()]; _structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
@@ -3391,7 +3394,7 @@ public sealed partial class AaruFormat
} }
else else
{ {
startCompress = DateTime.Now; compressStopwatch.Restart();
byte[] cmpBuffer = new byte[_sectorSuffix.Length + 262144]; byte[] cmpBuffer = new byte[_sectorSuffix.Length + 262144];
@@ -3429,10 +3432,10 @@ public sealed partial class AaruFormat
prefixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); prefixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0);
prefixBlock.compression = CompressionType.Lzma; prefixBlock.compression = CompressionType.Lzma;
endCompress = DateTime.Now; compressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_seconds_to_compress_suffix, AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_seconds_to_compress_suffix,
(endCompress - startCompress).TotalSeconds); compressStopwatch.Elapsed.TotalSeconds);
} }
_structureBytes = new byte[Marshal.SizeOf<BlockHeader>()]; _structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
@@ -3725,7 +3728,7 @@ public sealed partial class AaruFormat
} }
else else
{ {
startCompress = DateTime.Now; compressStopwatch.Restart();
byte[] sectorPrefixBuffer = _sectorPrefixMs.ToArray(); byte[] sectorPrefixBuffer = _sectorPrefixMs.ToArray();
cmpBuffer = new byte[sectorPrefixBuffer.Length + 262144]; cmpBuffer = new byte[sectorPrefixBuffer.Length + 262144];
@@ -3762,10 +3765,10 @@ public sealed partial class AaruFormat
prefixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); prefixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0);
prefixBlock.compression = _compressionAlgorithm; prefixBlock.compression = _compressionAlgorithm;
endCompress = DateTime.Now; compressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_seconds_to_compress_prefix, AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_seconds_to_compress_prefix,
(endCompress - startCompress).TotalSeconds); compressStopwatch.Elapsed.TotalSeconds);
} }
_structureBytes = new byte[Marshal.SizeOf<BlockHeader>()]; _structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
@@ -3819,7 +3822,7 @@ public sealed partial class AaruFormat
} }
else else
{ {
startCompress = DateTime.Now; compressStopwatch.Restart();
byte[] sectorSuffixBuffer = _sectorPrefixMs.ToArray(); byte[] sectorSuffixBuffer = _sectorPrefixMs.ToArray();
cmpBuffer = new byte[sectorSuffixBuffer.Length + 262144]; cmpBuffer = new byte[sectorSuffixBuffer.Length + 262144];
@@ -3856,10 +3859,10 @@ public sealed partial class AaruFormat
suffixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); suffixBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0);
suffixBlock.compression = _compressionAlgorithm; suffixBlock.compression = _compressionAlgorithm;
endCompress = DateTime.Now; compressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_seconds_to_compress_suffix, AaruConsole.DebugWriteLine("Aaru Format plugin", Localization.Took_0_seconds_to_compress_suffix,
(endCompress - startCompress).TotalSeconds); compressStopwatch.Elapsed.TotalSeconds);
} }
_structureBytes = new byte[Marshal.SizeOf<BlockHeader>()]; _structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
@@ -3916,7 +3919,7 @@ public sealed partial class AaruFormat
} }
else else
{ {
startCompress = DateTime.Now; compressStopwatch.Restart();
byte[] cmpBuffer = new byte[_mode2Subheaders.Length + 262144]; byte[] cmpBuffer = new byte[_mode2Subheaders.Length + 262144];
@@ -3954,11 +3957,11 @@ public sealed partial class AaruFormat
subheaderBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); subheaderBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0);
subheaderBlock.compression = _compressionAlgorithm; subheaderBlock.compression = _compressionAlgorithm;
endCompress = DateTime.Now; compressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_compress_MODE2_subheaders, Localization.Took_0_seconds_to_compress_MODE2_subheaders,
(endCompress - startCompress).TotalSeconds); compressStopwatch.Elapsed.TotalSeconds);
} }
_structureBytes = new byte[Marshal.SizeOf<BlockHeader>()]; _structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
@@ -4014,7 +4017,7 @@ public sealed partial class AaruFormat
} }
else else
{ {
startCompress = DateTime.Now; compressStopwatch.Restart();
byte[] transformedSubchannel = ClauniaSubchannelTransform(_sectorSubchannel); byte[] transformedSubchannel = ClauniaSubchannelTransform(_sectorSubchannel);
byte[] cmpBuffer = new byte[transformedSubchannel.Length + 262144]; byte[] cmpBuffer = new byte[transformedSubchannel.Length + 262144];
@@ -4056,11 +4059,11 @@ public sealed partial class AaruFormat
? CompressionType.LzmaClauniaSubchannelTransform ? CompressionType.LzmaClauniaSubchannelTransform
: _compressionAlgorithm; : _compressionAlgorithm;
endCompress = DateTime.Now; compressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_compress_subchannel, Localization.Took_0_seconds_to_compress_subchannel,
(endCompress - startCompress).TotalSeconds); compressStopwatch.Elapsed.TotalSeconds);
} }
_structureBytes = new byte[Marshal.SizeOf<BlockHeader>()]; _structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
@@ -4116,7 +4119,7 @@ public sealed partial class AaruFormat
} }
else else
{ {
startCompress = DateTime.Now; compressStopwatch.Restart();
byte[] cmpBuffer = new byte[_sectorCprMai.Length + 262144]; byte[] cmpBuffer = new byte[_sectorCprMai.Length + 262144];
@@ -4154,11 +4157,11 @@ public sealed partial class AaruFormat
cprMaiBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); cprMaiBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0);
cprMaiBlock.compression = _compressionAlgorithm; cprMaiBlock.compression = _compressionAlgorithm;
endCompress = DateTime.Now; compressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_compress_CPR_MAI, Localization.Took_0_seconds_to_compress_CPR_MAI,
(endCompress - startCompress).TotalSeconds); compressStopwatch.Elapsed.TotalSeconds);
} }
_structureBytes = new byte[Marshal.SizeOf<BlockHeader>()]; _structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
@@ -4211,7 +4214,7 @@ public sealed partial class AaruFormat
} }
else else
{ {
startCompress = DateTime.Now; compressStopwatch.Restart();
byte[] cmpBuffer = new byte[_sectorId.Length + 262144]; byte[] cmpBuffer = new byte[_sectorId.Length + 262144];
@@ -4249,11 +4252,11 @@ public sealed partial class AaruFormat
idBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); idBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0);
idBlock.compression = _compressionAlgorithm; idBlock.compression = _compressionAlgorithm;
endCompress = DateTime.Now; compressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_compress_ID, Localization.Took_0_seconds_to_compress_ID,
(endCompress - startCompress).TotalSeconds); compressStopwatch.Elapsed.TotalSeconds);
} }
_structureBytes = new byte[Marshal.SizeOf<BlockHeader>()]; _structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
@@ -4306,7 +4309,7 @@ public sealed partial class AaruFormat
} }
else else
{ {
startCompress = DateTime.Now; compressStopwatch.Restart();
byte[] cmpBuffer = new byte[_sectorIed.Length + 262144]; byte[] cmpBuffer = new byte[_sectorIed.Length + 262144];
@@ -4344,11 +4347,11 @@ public sealed partial class AaruFormat
iedBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); iedBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0);
iedBlock.compression = _compressionAlgorithm; iedBlock.compression = _compressionAlgorithm;
endCompress = DateTime.Now; compressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_compress_IED, Localization.Took_0_seconds_to_compress_IED,
(endCompress - startCompress).TotalSeconds); compressStopwatch.Elapsed.TotalSeconds);
} }
_structureBytes = new byte[Marshal.SizeOf<BlockHeader>()]; _structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
@@ -4401,7 +4404,7 @@ public sealed partial class AaruFormat
} }
else else
{ {
startCompress = DateTime.Now; compressStopwatch.Restart();
byte[] cmpBuffer = new byte[_sectorEdc.Length + 262144]; byte[] cmpBuffer = new byte[_sectorEdc.Length + 262144];
@@ -4439,11 +4442,11 @@ public sealed partial class AaruFormat
edcBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); edcBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0);
edcBlock.compression = _compressionAlgorithm; edcBlock.compression = _compressionAlgorithm;
endCompress = DateTime.Now; compressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_compress_EDC, Localization.Took_0_seconds_to_compress_EDC,
(endCompress - startCompress).TotalSeconds); compressStopwatch.Elapsed.TotalSeconds);
} }
_structureBytes = new byte[Marshal.SizeOf<BlockHeader>()]; _structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];
@@ -4497,7 +4500,7 @@ public sealed partial class AaruFormat
} }
else else
{ {
startCompress = DateTime.Now; compressStopwatch.Restart();
byte[] cmpBuffer = new byte[_sectorDecryptedTitleKey.Length + 262144]; byte[] cmpBuffer = new byte[_sectorDecryptedTitleKey.Length + 262144];
@@ -4535,11 +4538,11 @@ public sealed partial class AaruFormat
titleKeyBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0); titleKeyBlock.cmpCrc64 = BitConverter.ToUInt64(blockCrc, 0);
titleKeyBlock.compression = _compressionAlgorithm; titleKeyBlock.compression = _compressionAlgorithm;
endCompress = DateTime.Now; compressStopwatch.Stop();
AaruConsole.DebugWriteLine("Aaru Format plugin", AaruConsole.DebugWriteLine("Aaru Format plugin",
Localization.Took_0_seconds_to_compress_decrypted_DVD_title_keys, Localization.Took_0_seconds_to_compress_decrypted_DVD_title_keys,
(endCompress - startCompress).TotalSeconds); compressStopwatch.Elapsed.TotalSeconds);
} }
_structureBytes = new byte[Marshal.SizeOf<BlockHeader>()]; _structureBytes = new byte[Marshal.SizeOf<BlockHeader>()];

View File

@@ -32,6 +32,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@@ -75,7 +76,8 @@ public sealed partial class Chd
stream.Seek(0, SeekOrigin.Begin); stream.Seek(0, SeekOrigin.Begin);
stream.EnsureRead(buffer, 0, (int)length); stream.EnsureRead(buffer, 0, (int)length);
ulong nextMetaOff = 0; ulong nextMetaOff = 0;
var hunkMapStopwatch = new Stopwatch();
switch(version) switch(version)
{ {
@@ -103,8 +105,8 @@ public sealed partial class Chd
: ArrayHelpers.ByteArrayToHex(hdrV1.parentmd5)); : ArrayHelpers.ByteArrayToHex(hdrV1.parentmd5));
AaruConsole.DebugWriteLine("CHD plugin", Localization.Reading_Hunk_map); AaruConsole.DebugWriteLine("CHD plugin", Localization.Reading_Hunk_map);
DateTime start = DateTime.UtcNow;
hunkMapStopwatch.Restart();
_hunkTable = new ulong[hdrV1.totalhunks]; _hunkTable = new ulong[hdrV1.totalhunks];
uint hunkSectorCount = (uint)Math.Ceiling((double)hdrV1.totalhunks * 8 / 512); uint hunkSectorCount = (uint)Math.Ceiling((double)hdrV1.totalhunks * 8 / 512);
@@ -128,8 +130,10 @@ public sealed partial class Chd
Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, i * 512 / 8, _hunkTable.Length - (i * 512 / 8)); Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, i * 512 / 8, _hunkTable.Length - (i * 512 / 8));
} }
DateTime end = DateTime.UtcNow; hunkMapStopwatch.Stop();
AaruConsole.DebugWriteLine("CHD plugin", Localization.Took_0_seconds, (end - start).TotalSeconds);
AaruConsole.DebugWriteLine("CHD plugin", Localization.Took_0_seconds,
hunkMapStopwatch.Elapsed.TotalSeconds);
_imageInfo.MediaType = MediaType.GENERIC_HDD; _imageInfo.MediaType = MediaType.GENERIC_HDD;
_imageInfo.Sectors = hdrV1.hunksize * hdrV1.totalhunks; _imageInfo.Sectors = hdrV1.hunksize * hdrV1.totalhunks;
@@ -177,7 +181,7 @@ public sealed partial class Chd
AaruConsole.DebugWriteLine("CHD plugin", "hdrV2.seclen = {0}", hdrV2.seclen); AaruConsole.DebugWriteLine("CHD plugin", "hdrV2.seclen = {0}", hdrV2.seclen);
AaruConsole.DebugWriteLine("CHD plugin", Localization.Reading_Hunk_map); AaruConsole.DebugWriteLine("CHD plugin", Localization.Reading_Hunk_map);
DateTime start = DateTime.UtcNow; hunkMapStopwatch.Restart();
_hunkTable = new ulong[hdrV2.totalhunks]; _hunkTable = new ulong[hdrV2.totalhunks];
@@ -203,8 +207,10 @@ public sealed partial class Chd
Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, i * 512 / 8, _hunkTable.Length - (i * 512 / 8)); Array.Copy(hunkSector.hunkEntry, 0, _hunkTable, i * 512 / 8, _hunkTable.Length - (i * 512 / 8));
} }
DateTime end = DateTime.UtcNow; hunkMapStopwatch.Stop();
AaruConsole.DebugWriteLine("CHD plugin", Localization.Took_0_seconds, (end - start).TotalSeconds);
AaruConsole.DebugWriteLine("CHD plugin", Localization.Took_0_seconds,
hunkMapStopwatch.Elapsed.TotalSeconds);
_imageInfo.MediaType = MediaType.GENERIC_HDD; _imageInfo.MediaType = MediaType.GENERIC_HDD;
_imageInfo.Sectors = hdrV2.hunksize * hdrV2.totalhunks; _imageInfo.Sectors = hdrV2.hunksize * hdrV2.totalhunks;
@@ -256,13 +262,15 @@ public sealed partial class Chd
: ArrayHelpers.ByteArrayToHex(hdrV3.parentsha1)); : ArrayHelpers.ByteArrayToHex(hdrV3.parentsha1));
AaruConsole.DebugWriteLine("CHD plugin", Localization.Reading_Hunk_map); AaruConsole.DebugWriteLine("CHD plugin", Localization.Reading_Hunk_map);
DateTime start = DateTime.UtcNow; hunkMapStopwatch.Restart();
_hunkMap = new byte[hdrV3.totalhunks * 16]; _hunkMap = new byte[hdrV3.totalhunks * 16];
stream.EnsureRead(_hunkMap, 0, _hunkMap.Length); stream.EnsureRead(_hunkMap, 0, _hunkMap.Length);
DateTime end = DateTime.UtcNow; hunkMapStopwatch.Stop();
AaruConsole.DebugWriteLine("CHD plugin", Localization.Took_0_seconds, (end - start).TotalSeconds);
AaruConsole.DebugWriteLine("CHD plugin", Localization.Took_0_seconds,
hunkMapStopwatch.Elapsed.TotalSeconds);
nextMetaOff = hdrV3.metaoffset; nextMetaOff = hdrV3.metaoffset;
@@ -304,13 +312,15 @@ public sealed partial class Chd
ArrayHelpers.ByteArrayToHex(hdrV4.rawsha1)); ArrayHelpers.ByteArrayToHex(hdrV4.rawsha1));
AaruConsole.DebugWriteLine("CHD plugin", Localization.Reading_Hunk_map); AaruConsole.DebugWriteLine("CHD plugin", Localization.Reading_Hunk_map);
DateTime start = DateTime.UtcNow; hunkMapStopwatch.Restart();
_hunkMap = new byte[hdrV4.totalhunks * 16]; _hunkMap = new byte[hdrV4.totalhunks * 16];
stream.EnsureRead(_hunkMap, 0, _hunkMap.Length); stream.EnsureRead(_hunkMap, 0, _hunkMap.Length);
DateTime end = DateTime.UtcNow; hunkMapStopwatch.Stop();
AaruConsole.DebugWriteLine("CHD plugin", Localization.Took_0_seconds, (end - start).TotalSeconds);
AaruConsole.DebugWriteLine("CHD plugin", Localization.Took_0_seconds,
hunkMapStopwatch.Elapsed.TotalSeconds);
nextMetaOff = hdrV4.metaoffset; nextMetaOff = hdrV4.metaoffset;
@@ -370,7 +380,7 @@ public sealed partial class Chd
if(hdrV5.compressor0 == 0) if(hdrV5.compressor0 == 0)
{ {
AaruConsole.DebugWriteLine("CHD plugin", Localization.Reading_Hunk_map); AaruConsole.DebugWriteLine("CHD plugin", Localization.Reading_Hunk_map);
DateTime start = DateTime.UtcNow; hunkMapStopwatch.Restart();
_hunkTableSmall = new uint[hdrV5.logicalbytes / hdrV5.hunkbytes]; _hunkTableSmall = new uint[hdrV5.logicalbytes / hdrV5.hunkbytes];
@@ -400,8 +410,10 @@ public sealed partial class Chd
_hunkTableSmall.Length - (i * 512 / 4)); _hunkTableSmall.Length - (i * 512 / 4));
} }
DateTime end = DateTime.UtcNow; hunkMapStopwatch.Stop();
AaruConsole.DebugWriteLine("CHD plugin", Localization.Took_0_seconds, (end - start).TotalSeconds);
AaruConsole.DebugWriteLine("CHD plugin", Localization.Took_0_seconds,
hunkMapStopwatch.Elapsed.TotalSeconds);
} }
else else
{ {

View File

@@ -30,8 +30,8 @@
// Copyright © 2011-2023 Natalia Portillo // Copyright © 2011-2023 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Aaru.CommonTypes; using Aaru.CommonTypes;
@@ -90,7 +90,8 @@ public sealed partial class PartClone
AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.dataOff = {0}", _dataOff); AaruConsole.DebugWriteLine("PartClone plugin", "pHdr.dataOff = {0}", _dataOff);
AaruConsole.DebugWriteLine("PartClone plugin", Localization.Filling_extents); AaruConsole.DebugWriteLine("PartClone plugin", Localization.Filling_extents);
DateTime start = DateTime.Now; var extentFillStopwatch = new Stopwatch();
extentFillStopwatch.Start();
_extents = new ExtentsULong(); _extents = new ExtentsULong();
_extentsOff = new Dictionary<ulong, ulong>(); _extentsOff = new Dictionary<ulong, ulong>();
bool current = _byteMap[0] > 0; bool current = _byteMap[0] > 0;
@@ -120,10 +121,10 @@ public sealed partial class PartClone
current = next; current = next;
} }
DateTime end = DateTime.Now; extentFillStopwatch.Stop();
AaruConsole.DebugWriteLine("PartClone plugin", Localization.Took_0_seconds_to_fill_extents, AaruConsole.DebugWriteLine("PartClone plugin", Localization.Took_0_seconds_to_fill_extents,
(end - start).TotalSeconds); extentFillStopwatch.Elapsed.TotalSeconds);
_sectorCache = new Dictionary<ulong, byte[]>(); _sectorCache = new Dictionary<ulong, byte[]>();

View File

@@ -32,6 +32,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using Aaru.CommonTypes; using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Enums;
@@ -325,7 +326,8 @@ public sealed partial class Partimage
} }
AaruConsole.DebugWriteLine("Partimage plugin", Localization.Filling_extents); AaruConsole.DebugWriteLine("Partimage plugin", Localization.Filling_extents);
DateTime start = DateTime.Now; var extentsFillStopwatch = new Stopwatch();
extentsFillStopwatch.Start();
_extents = new ExtentsULong(); _extents = new ExtentsULong();
_extentsOff = new Dictionary<ulong, ulong>(); _extentsOff = new Dictionary<ulong, ulong>();
bool current = (_bitmap[0] & (1 << (0 % 8))) != 0; bool current = (_bitmap[0] & (1 << (0 % 8))) != 0;
@@ -355,10 +357,10 @@ public sealed partial class Partimage
current = next; current = next;
} }
DateTime end = DateTime.Now; extentsFillStopwatch.Stop();
AaruConsole.DebugWriteLine("Partimage plugin", Localization.Took_0_seconds_to_fill_extents, AaruConsole.DebugWriteLine("Partimage plugin", Localization.Took_0_seconds_to_fill_extents,
(end - start).TotalSeconds); extentsFillStopwatch.Elapsed.TotalSeconds);
_sectorCache = new Dictionary<ulong, byte[]>(); _sectorCache = new Dictionary<ulong, byte[]>();

View File

@@ -32,6 +32,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Aaru.CommonTypes; using Aaru.CommonTypes;
@@ -96,16 +97,17 @@ public sealed partial class Vdi
return ErrorNumber.InvalidArgument; return ErrorNumber.InvalidArgument;
} }
DateTime start = DateTime.UtcNow; var blockMapStopwatch = new Stopwatch();
blockMapStopwatch.Start();
AaruConsole.DebugWriteLine("VirtualBox plugin", Localization.Reading_Image_Block_Map); AaruConsole.DebugWriteLine("VirtualBox plugin", Localization.Reading_Image_Block_Map);
stream.Seek(_vHdr.offsetBlocks, SeekOrigin.Begin); stream.Seek(_vHdr.offsetBlocks, SeekOrigin.Begin);
byte[] ibmB = new byte[_vHdr.blocks * 4]; byte[] ibmB = new byte[_vHdr.blocks * 4];
stream.EnsureRead(ibmB, 0, ibmB.Length); stream.EnsureRead(ibmB, 0, ibmB.Length);
_ibm = MemoryMarshal.Cast<byte, uint>(ibmB).ToArray(); _ibm = MemoryMarshal.Cast<byte, uint>(ibmB).ToArray();
DateTime end = DateTime.UtcNow; blockMapStopwatch.Stop();
AaruConsole.DebugWriteLine("VirtualBox plugin", Localization.Reading_Image_Block_Map_took_0_ms, AaruConsole.DebugWriteLine("VirtualBox plugin", Localization.Reading_Image_Block_Map_took_0_ms,
(end - start).TotalMilliseconds); blockMapStopwatch.Elapsed.TotalMilliseconds);
_sectorCache = new Dictionary<ulong, byte[]>(); _sectorCache = new Dictionary<ulong, byte[]>();

View File

@@ -31,6 +31,7 @@
// ****************************************************************************/ // ****************************************************************************/
using System; using System;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
@@ -475,7 +476,8 @@ public sealed partial class Vhd
return ErrorNumber.InvalidArgument; return ErrorNumber.InvalidArgument;
} }
DateTime startTime = DateTime.UtcNow; var batStopwatch = new Stopwatch();
batStopwatch.Start();
_blockAllocationTable = new uint[_thisDynamic.MaxTableEntries]; _blockAllocationTable = new uint[_thisDynamic.MaxTableEntries];
@@ -490,10 +492,10 @@ public sealed partial class Vhd
for(int i = 0; i < _blockAllocationTable.Length; i++) for(int i = 0; i < _blockAllocationTable.Length; i++)
_blockAllocationTable[i] = Swapping.Swap(_blockAllocationTable[i]); _blockAllocationTable[i] = Swapping.Swap(_blockAllocationTable[i]);
DateTime endTime = DateTime.UtcNow; batStopwatch.Stop();
AaruConsole.DebugWriteLine("VirtualPC plugin", Localization.Filling_the_BAT_took_0_seconds, AaruConsole.DebugWriteLine("VirtualPC plugin", Localization.Filling_the_BAT_took_0_seconds,
(endTime - startTime).TotalSeconds); batStopwatch.Elapsed.TotalSeconds);
_bitmapSize = (uint)Math.Ceiling((double)_thisDynamic.BlockSize / 512 _bitmapSize = (uint)Math.Ceiling((double)_thisDynamic.BlockSize / 512

View File

@@ -30,10 +30,10 @@
// Copyright © 2011-2023 Natalia Portillo // Copyright © 2011-2023 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.CommandLine; using System.CommandLine;
using System.CommandLine.NamingConventionBinder; using System.CommandLine.NamingConventionBinder;
using System.Diagnostics;
using System.IO; using System.IO;
using Aaru.CommonTypes; using Aaru.CommonTypes;
using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Enums;
@@ -188,21 +188,19 @@ sealed class VerifyCommand : Command
return (int)ErrorNumber.NotVerifiable; return (int)ErrorNumber.NotVerifiable;
} }
TimeSpan checkTime; var chkWatch = new Stopwatch();
if(verifyDisc && verifiableImage != null) if(verifyDisc && verifiableImage != null)
{ {
bool? discCheckStatus = null; bool? discCheckStatus = null;
checkTime = new TimeSpan();
Core.Spectre.ProgressSingleSpinner(ctx => Core.Spectre.ProgressSingleSpinner(ctx =>
{ {
ctx.AddTask(UI.Verifying_image_checksums).IsIndeterminate(); ctx.AddTask(UI.Verifying_image_checksums).IsIndeterminate();
DateTime startCheck = DateTime.UtcNow; chkWatch.Start();
discCheckStatus = verifiableImage.VerifyMediaImage(); discCheckStatus = verifiableImage.VerifyMediaImage();
DateTime endCheck = DateTime.UtcNow; chkWatch.Stop();
checkTime = endCheck - startCheck;
}); });
switch(discCheckStatus) switch(discCheckStatus)
@@ -222,7 +220,9 @@ sealed class VerifyCommand : Command
} }
correctImage = discCheckStatus; correctImage = discCheckStatus;
AaruConsole.VerboseWriteLine(UI.Checking_disc_image_checksums_took_0, checkTime.Humanize(minUnit: TimeUnit.Second));
AaruConsole.VerboseWriteLine(UI.Checking_disc_image_checksums_took_0,
chkWatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
} }
if(!verifySectors) if(!verifySectors)
@@ -233,8 +233,7 @@ sealed class VerifyCommand : Command
true => (int)ErrorNumber.CorrectImageSectorsNotVerified true => (int)ErrorNumber.CorrectImageSectorsNotVerified
}; };
DateTime startCheck = DateTime.Now; var stopwatch = new Stopwatch();
DateTime endCheck = startCheck;
List<ulong> failingLbas = new(); List<ulong> failingLbas = new();
List<ulong> unknownLbas = new(); List<ulong> unknownLbas = new();
IMediaGraph mediaGraph = null; IMediaGraph mediaGraph = null;
@@ -255,7 +254,7 @@ sealed class VerifyCommand : Command
List<Track> inputTracks = opticalMediaImage.Tracks; List<Track> inputTracks = opticalMediaImage.Tracks;
ulong currentSectorAll = 0; ulong currentSectorAll = 0;
startCheck = DateTime.UtcNow; stopwatch.Start();
AnsiConsole.Progress().AutoClear(true).HideCompleted(true). AnsiConsole.Progress().AutoClear(true).HideCompleted(true).
Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()). Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn()).
@@ -340,7 +339,7 @@ sealed class VerifyCommand : Command
discTask.Increment(1); discTask.Increment(1);
} }
endCheck = DateTime.UtcNow; stopwatch.Stop();
}); });
} }
else if(verifiableSectorsImage != null) else if(verifiableSectorsImage != null)
@@ -355,7 +354,7 @@ sealed class VerifyCommand : Command
ProgressTask diskTask = ctx.AddTask(UI.Checking_sectors); ProgressTask diskTask = ctx.AddTask(UI.Checking_sectors);
diskTask.MaxValue = inputFormat.Info.Sectors; diskTask.MaxValue = inputFormat.Info.Sectors;
startCheck = DateTime.UtcNow; stopwatch.Restart();
while(remainingSectors > 0) while(remainingSectors > 0)
{ {
@@ -408,12 +407,10 @@ sealed class VerifyCommand : Command
} }
} }
endCheck = DateTime.UtcNow; stopwatch.Stop();
}); });
} }
checkTime = endCheck - startCheck;
if(unknownLbas.Count > 0) if(unknownLbas.Count > 0)
AaruConsole.WriteLine(UI.There_is_at_least_one_sector_that_does_not_contain_a_checksum); AaruConsole.WriteLine(UI.There_is_at_least_one_sector_that_does_not_contain_a_checksum);
@@ -424,7 +421,8 @@ sealed class VerifyCommand : Command
failingLbas.Count == 0) failingLbas.Count == 0)
AaruConsole.WriteLine(UI.All_sector_checksums_are_correct); AaruConsole.WriteLine(UI.All_sector_checksums_are_correct);
AaruConsole.VerboseWriteLine(UI.Checking_sector_checksums_took_0, checkTime.Humanize(minUnit: TimeUnit.Second)); AaruConsole.VerboseWriteLine(UI.Checking_sector_checksums_took_0,
stopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
if(verbose) if(verbose)
{ {

0
build.sh Normal file → Executable file
View File