Skip to content

Commit

Permalink
feat: 6pack progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ikpil committed Oct 1, 2023
1 parent c80dfe3 commit 34ff244
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/DotFastLZ.SixPack/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,16 @@ public static int pack_file_compressed(string input_file, int method, int level,

/* for progress status */
string progress;
if (13 < fileName.Length)
if (16 < fileName.Length)
{
progress = fileName.Substring(0, 13);
progress += ".. ";
}
else
{
progress = fileName.PadRight(13, ' ');
progress = fileName.PadRight(16, ' ');
}

progress += ".. ";

Console.Write($"{progress} [");
for (int c = 0; c < 50; c++)
Expand Down Expand Up @@ -324,19 +324,24 @@ public static int pack_file_compressed(string input_file, int method, int level,
}
else
{
Console.WriteLine("] ");
Console.Write("] ");
if (total_compressed < fsize)
{
if (fsize < (1 << 20))
{
percent = total_compressed * 1000 / fsize;
}
else
{
percent = total_compressed / 256 * 1000 / (fsize >> 8);
}

percent = 1000 - percent;

var elapsedTicks = (DateTime.UtcNow.Ticks - beginTick);
var elapsedMs = elapsedTicks / TimeSpan.TicksPerMillisecond;
var elapsedMicro = elapsedTicks / TimeSpan.TicksPerMicrosecond;
Console.Write($"{(int)percent / 10:D2}.{(int)percent % 10:D1}%% saved - {elapsedMs} ms, {elapsedMicro} micro");
Console.Write($"{(int)percent / 10:D2}.{(int)percent % 10:D1}% saved - {elapsedMs} ms, {elapsedMicro} micro");
}

Console.WriteLine("");
Expand Down

0 comments on commit 34ff244

Please sign in to comment.