Skip to content

Commit

Permalink
Added iteration count to TestApp
Browse files Browse the repository at this point in the history
  • Loading branch information
TechPizzaDev committed Aug 31, 2023
1 parent 043ffcf commit d50a5d1
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions TestApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ static void DecodeFile(string sourceFile, string? destinationFile)

byte[] bytes = File.ReadAllBytes(sourceFile);

for (int j = 0; j < 2; j++)
int iterationCount = 2;

Console.WriteLine(" Comparing seek vs forward decode");
for (int j = 0; j < iterationCount; j++)
{
Console.WriteLine($" Iteration {j + 1}");

Decode(bytes, (vorbRead1, vorbRead2) =>
{
if (j != 0)
if (j % 2 != 0)
{
vorbRead1.ClipSamples = false;
vorbRead2.ClipSamples = false;
}
Console.WriteLine(" Comparing seek vs forward decode");
do
{
int cnt1 = vorbRead1.ReadSamples(sampleBuf1);
Expand All @@ -78,12 +80,18 @@ static void DecodeFile(string sourceFile, string? destinationFile)
}
while (true);
});
FullGC();
}
FullGC();

Console.WriteLine($" Writing interleaved {destinationFile}");
for (int j = 0; j < iterationCount; j++)
{
Console.WriteLine($" Iteration {j + 1}");

Decode(bytes, (vorbRead1, vorbRead2) =>
{
string? fileName = destinationFile;
if (j != 0)
if (j % 2 != 0)
{
vorbRead1.ClipSamples = false;
vorbRead2.ClipSamples = false;
Expand All @@ -92,7 +100,6 @@ static void DecodeFile(string sourceFile, string? destinationFile)
fileName = AppendToFileName(fileName, "-noclip");
}
Console.WriteLine($" Writing interleaved {fileName}");
int channels = vorbRead1.Channels;
using (WaveWriter writer = new(CreateWriteStream(fileName), false, vorbRead1.SampleRate, channels))
{
Expand All @@ -103,7 +110,13 @@ static void DecodeFile(string sourceFile, string? destinationFile)
}
}
});
FullGC();
}
FullGC();

Console.WriteLine($" Writing non-interleaved {destinationFile}");
for (int j = 0; j < iterationCount; j++)
{
Console.WriteLine($" Iteration {j + 1}");

Decode(bytes, (vorbRead1, vorbRead2) =>
{
Expand All @@ -114,15 +127,14 @@ static void DecodeFile(string sourceFile, string? destinationFile)
}
string? fileName = destinationFile;
if (j != 0)
if (j % 2 != 0)
{
vorbRead1.ClipSamples = false;
vorbRead2.ClipSamples = false;
if (fileName != null)
fileName = AppendToFileName(fileName, "-noclip");
}
Console.WriteLine($" Writing non-interleaved {fileName}");
string? leftFile = fileName != null ? AppendToFileName(fileName, "-left") : null;
string? rightFile = fileName != null ? AppendToFileName(fileName, "-right") : null;
Expand All @@ -140,8 +152,8 @@ static void DecodeFile(string sourceFile, string? destinationFile)
}
}
});
FullGC();
}
FullGC();
}

public static void Decode(byte[] bytes, Action<VorbisReader, VorbisReader> action)
Expand Down

0 comments on commit d50a5d1

Please sign in to comment.