mirror of
https://github.com/aaru-dps/AaruBenchmark.git
synced 2025-12-16 19:24:36 +00:00
Add FLAC tests.
This commit is contained in:
@@ -50,6 +50,10 @@
|
||||
<Content Include="data\lzma.bin">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Remove="data\flac.flac"/>
|
||||
<Content Include="data\flac.flac">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -85,6 +85,16 @@ namespace AaruBenchmark
|
||||
public void AaruNative() => Compression.AaruNative.Lzma();
|
||||
}
|
||||
|
||||
[SimpleJob(RuntimeMoniker.Net60)]
|
||||
public class FlacBenchs
|
||||
{
|
||||
[Benchmark(Baseline = true)]
|
||||
public void Aaru() => Compression.Aaru.Flac();
|
||||
|
||||
[Benchmark]
|
||||
public void AaruNative() => Compression.AaruNative.Flac();
|
||||
}
|
||||
|
||||
[SimpleJob(RuntimeMoniker.Net60)]
|
||||
public class Adler32Benchs
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.IO;
|
||||
using Aaru.Compression;
|
||||
using Aaru6.Checksums;
|
||||
using CUETools.Codecs;
|
||||
using CUETools.Codecs.Flake;
|
||||
|
||||
namespace AaruBenchmark.Compression
|
||||
{
|
||||
@@ -69,5 +71,22 @@ namespace AaruBenchmark.Compression
|
||||
if(crc != "22bd5d44")
|
||||
throw new InvalidDataException("Incorrect decompressed checksum");
|
||||
}
|
||||
|
||||
public static void Flac()
|
||||
{
|
||||
var flacMs = new FileStream(Path.Combine(Program.Folder, "flac.flac"), FileMode.Open, FileAccess.Read);
|
||||
var flakeReader = new AudioDecoder(new DecoderSettings(), "", flacMs);
|
||||
byte[] block = new byte[9633792];
|
||||
int samples = block.Length / 2352 * 588;
|
||||
var audioBuffer = new AudioBuffer(AudioPCMConfig.RedBook, block, samples);
|
||||
flakeReader.Read(audioBuffer, samples);
|
||||
flakeReader.Close();
|
||||
flacMs.Close();
|
||||
|
||||
string crc = Crc32Context.Data(block, out _);
|
||||
|
||||
if(crc != "dfbc99bb")
|
||||
throw new InvalidDataException("Incorrect decompressed checksum");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,10 @@ namespace AaruBenchmark.Compression
|
||||
static extern int LzmaUncompress(byte[] dest, ref nuint destLen, byte[] src, ref nuint srcLen, byte[] props,
|
||||
nuint propsSize);
|
||||
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
static extern nuint flac_decode_redbook_buffer(byte[] dst_buffer, nuint dst_size, byte[] src_buffer,
|
||||
nuint src_size);
|
||||
|
||||
public static void AppleRle()
|
||||
{
|
||||
const int bufferSize = 32768;
|
||||
@@ -152,5 +156,29 @@ namespace AaruBenchmark.Compression
|
||||
if(crc != "954bf76e")
|
||||
throw new InvalidDataException("Incorrect decompressed checksum");
|
||||
}
|
||||
|
||||
public static void Flac()
|
||||
{
|
||||
const int bufferSize = 9633792;
|
||||
byte[] input = new byte[6534197];
|
||||
|
||||
var fs = new FileStream(Path.Combine(Program.Folder, "flac.flac"), FileMode.Open, FileAccess.Read);
|
||||
|
||||
fs.Read(input, 0, input.Length);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
|
||||
byte[] output = new byte[bufferSize];
|
||||
|
||||
ulong realSize = flac_decode_redbook_buffer(output, (nuint)output.Length, input, (nuint)input.Length);
|
||||
|
||||
if(realSize != 9633792)
|
||||
throw new InvalidDataException("Incorrect decompressed size");
|
||||
|
||||
string crc = Crc32Context.Data(output, (uint)realSize, out _);
|
||||
|
||||
if(crc != "dfbc99bb")
|
||||
throw new InvalidDataException("Incorrect decompressed checksum");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ namespace AaruBenchmark
|
||||
BenchmarkRunner.Run<Bzip2Benchs>(config);
|
||||
BenchmarkRunner.Run<LzipBenchs>(config);
|
||||
BenchmarkRunner.Run<LzmaBenchs>(config);
|
||||
BenchmarkRunner.Run<FlacBenchs>(config);
|
||||
BenchmarkRunner.Run<Adler32Benchs>(config);
|
||||
BenchmarkRunner.Run<Crc16CcittBenchs>(config);
|
||||
BenchmarkRunner.Run<Crc16Benchs>(config);
|
||||
|
||||
BIN
AaruBenchmark/data/flac.flac
Normal file
BIN
AaruBenchmark/data/flac.flac
Normal file
Binary file not shown.
Reference in New Issue
Block a user