Skip to content

Commit

Permalink
Fix byte speed rates not being properly "humanized".
Browse files Browse the repository at this point in the history
  • Loading branch information
claunia committed Sep 26, 2023
1 parent 25c5cba commit 8786474
Show file tree
Hide file tree
Showing 22 changed files with 110 additions and 87 deletions.
26 changes: 16 additions & 10 deletions Aaru.Core/Devices/Dumping/ATA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void Ata()
minSpeed = currentSpeed;

UpdateProgress?.
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)),
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);

bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration, out _, out _);
Expand Down Expand Up @@ -397,11 +397,12 @@ void Ata()
(end - start).Humanize(minUnit: TimeUnit.Second)));

_dumpLog.WriteLine(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()));
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()).
Humanize());

_dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(imageWriteDuration.Seconds())));
Per(imageWriteDuration.Seconds()).Humanize()));

#region Trimming
if(_resume.BadBlocks.Count > 0 &&
Expand Down Expand Up @@ -592,7 +593,9 @@ void Ata()

PulseProgress?.
Invoke(string.Format(Localization.Core.Reading_cylinder_0_head_1_sector_2_3, cy, hd,
sc, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)));
sc,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).
Humanize()));

bool error =
ataReader.ReadChs(out cmdBuf, cy, hd, sc, out duration, out recoveredError);
Expand Down Expand Up @@ -668,10 +671,12 @@ void Ata()
(end - start).Humanize(minUnit: TimeUnit.Second)));

_dumpLog.WriteLine(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()));
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()).
Humanize());

_dumpLog.WriteLine(Localization.Core.Average_write_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(imageWriteDuration.Seconds()));
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(imageWriteDuration.Seconds()).
Humanize());
}

foreach(ulong bad in _resume.BadBlocks)
Expand Down Expand Up @@ -866,7 +871,8 @@ void Ata()
(chkEnd - chkStart).Humanize(minUnit: TimeUnit.Second));

_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()));
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds()).Humanize());

List<(ulong start, string type)> filesystems = new();

Expand Down Expand Up @@ -940,15 +946,15 @@ from fileSystem in partition.FileSystems

UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds())));
Per(totalDuration.Milliseconds()).Humanize()));

if(maxSpeed > 0)
UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0,
ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond)));
ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize()));

if(minSpeed is > 0 and < double.MaxValue)
UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0,
ByteSize.FromMegabytes(minSpeed).Per(_oneSecond)));
ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize()));

UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read,
_resume.BadBlocks.Count));
Expand Down
12 changes: 6 additions & 6 deletions Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void ReadCdiReady(uint blockSize, ref double currentSpeed, DumpHardware currentT
minSpeed = currentSpeed;

UpdateProgress?.
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)),
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);

sense = _dev.ReadCd(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead,
Expand All @@ -232,7 +232,7 @@ void ReadCdiReady(uint blockSize, ref double currentSpeed, DumpHardware currentT
for(uint r = 0; r < _maximumReadable; r++)
{
UpdateProgress?.
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)),
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i + r, (long)blocks);

sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(i + r), blockSize, (uint)sectorsForOffset + 1,
Expand Down Expand Up @@ -354,10 +354,10 @@ void ReadCdiReady(uint blockSize, ref double currentSpeed, DumpHardware currentT
outputOptical.WriteSectorsLong(data, i, blocksToRead);

bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, 1, ref mcn, tracks,
subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel,
_fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true,
out List<ulong> newPregapSectors);
desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, 1, ref mcn, tracks,
subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel,
_fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true,
out List<ulong> newPregapSectors);

// Set tracks and go back
if(indexesChanged)
Expand Down
12 changes: 6 additions & 6 deletions Aaru.Core/Devices/Dumping/CompactDisc/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void ReadCdData(ExtentsULong audioExtents, ulong blocks, uint blockSize, ref dou
minSpeed = currentSpeed;

UpdateProgress?.
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)),
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i, (long)blocks);

if(crossingLeadOut &&
Expand Down Expand Up @@ -425,7 +425,7 @@ void ReadCdData(ExtentsULong audioExtents, ulong blocks, uint blockSize, ref dou
for(uint r = 0; r < blocksToRead; r++)
{
UpdateProgress?.
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)),
Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i + r, (long)blocks);

if(_supportsPlextorD8)
Expand Down Expand Up @@ -673,10 +673,10 @@ void ReadCdData(ExtentsULong audioExtents, ulong blocks, uint blockSize, ref dou
}

bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, (byte)track.Sequence, ref mcn,
tracks, subchannelExtents, _fixSubchannelPosition, outputFormat as IWritableOpticalImage,
_fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true,
out List<ulong> newPregapSectors);
desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, (byte)track.Sequence, ref mcn,
tracks, subchannelExtents, _fixSubchannelPosition, outputFormat as IWritableOpticalImage,
_fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true,
out List<ulong> newPregapSectors);

// Set tracks and go back
if(indexesChanged)
Expand Down
7 changes: 4 additions & 3 deletions Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,14 +1474,15 @@ void CompactDisc()

UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds())));
Per(totalDuration.Milliseconds()).Humanize()));

if(maxSpeed > 0)
UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0,
ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize()));

if(minSpeed is > 0 and < double.MaxValue)
UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0,
ByteSize.FromMegabytes(minSpeed).Per(_oneSecond)));
ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize()));

UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count));

Expand Down
4 changes: 2 additions & 2 deletions Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void DumpCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardware curren
minSpeed = currentSpeed;

PulseProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_at_lead_out_1, i,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)));
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()));

if(readcd)
{
Expand Down Expand Up @@ -294,7 +294,7 @@ void RetryCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardware curre
minSpeed = currentSpeed;

PulseProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_at_lead_out_1, i,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)));
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()));

if(readcd)
{
Expand Down
2 changes: 1 addition & 1 deletion Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void ReadCdFirstTrackPregap(uint blockSize, ref double currentSpeed, Dictionary<

PulseProgress?.Invoke(string.Format(Localization.Core.Trying_to_read_first_track_pregap_sector_0_1,
firstTrackPregapBlock,
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)));
ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()));

// ReSharper disable IntVariableOverflowInUncheckedContext
sense = _dev.ReadCd(out cmdBuf, out _, (uint)firstTrackPregapBlock, blockSize, 1, MmcSectorTypes.AllTypes,
Expand Down
19 changes: 11 additions & 8 deletions Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ void Retrode()
minSpeed = currentSpeed;

UpdateProgress?.
Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, i * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)),
Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, i * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)i * 512, romSize);

sense = _dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)(startSector + i),
Expand Down Expand Up @@ -373,7 +373,7 @@ void Retrode()
minSpeed = currentSpeed;

UpdateProgress?.
Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, romSectors * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)),
Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, romSectors * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()),
(long)romSectors * 512, romSize);

sense = _dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, romSectors, 512, 0, 1,
Expand Down Expand Up @@ -417,10 +417,12 @@ void Retrode()
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, (end - start).Humanize(minUnit: TimeUnit.Second)));

_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()).
Humanize()));

_dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0,
ByteSize.FromBytes(512 * (romSectors + 1)).Per(imageWriteDuration.Seconds())));
ByteSize.FromBytes(512 * (romSectors + 1)).Per(imageWriteDuration.Seconds()).
Humanize()));

var metadata = new CommonTypes.Structs.ImageInfo
{
Expand Down Expand Up @@ -470,15 +472,16 @@ void Retrode()
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)));

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()).
Humanize()));

if(maxSpeed > 0)
UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond)));
UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0,
ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize()));

if(minSpeed is > 0 and < double.MaxValue)
UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0,
ByteSize.FromMegabytes(minSpeed).Per(_oneSecond)));
ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize()));

UpdateStatus?.Invoke("");

Expand Down
3 changes: 2 additions & 1 deletion Aaru.Core/Devices/Dumping/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ void WriteOpticalSidecar(uint blockSize, ulong blocks, MediaType mediaType, Laye
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, (end - chkStart).Humanize(minUnit: TimeUnit.Second));

_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()));
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()).
Humanize());

if(_preSidecar != null)
{
Expand Down
Loading

0 comments on commit 8786474

Please sign in to comment.