mirror of
https://github.com/aaru-dps/AaruBenchmark.git
synced 2025-12-16 19:24:36 +00:00
Implement native benchmark for Apple RLE.
This commit is contained in:
@@ -34,6 +34,10 @@
|
||||
<Content Include="data\teledisk_lzh.bin">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Remove="libAaru.Compression.Native.so"/>
|
||||
<Content Include="libAaru.Compression.Native.so">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace AaruBenchmark
|
||||
|
||||
[Benchmark]
|
||||
public void Aaru6() => Aaru6Compressions.AppleRle();
|
||||
|
||||
[Benchmark]
|
||||
public void AaruNative() => Compression.AaruNative.AppleRle();
|
||||
}
|
||||
|
||||
[SimpleJob(RuntimeMoniker.Net60)]
|
||||
|
||||
36
AaruBenchmark/Compression/AaruNative.cs
Normal file
36
AaruBenchmark/Compression/AaruNative.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Aaru6.Checksums;
|
||||
|
||||
namespace AaruBenchmark.Compression
|
||||
{
|
||||
public class AaruNative
|
||||
{
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
static extern int apple_rle_decode_buffer(byte[] dst_buffer, int dst_size, byte[] src_buffer, int src_size);
|
||||
|
||||
public static void AppleRle()
|
||||
{
|
||||
const int bufferSize = 32768;
|
||||
byte[] input = new byte[1102];
|
||||
|
||||
var fs = new FileStream(Path.Combine(Program.Folder, "apple_rle.bin"), FileMode.Open, FileAccess.Read);
|
||||
|
||||
fs.Read(input, 0, input.Length);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
|
||||
byte[] output = new byte[bufferSize];
|
||||
|
||||
int realSize = apple_rle_decode_buffer(output, output.Length, input, input.Length);
|
||||
|
||||
if(realSize != 20960)
|
||||
throw new InvalidDataException("Incorrect decompressed size");
|
||||
|
||||
string crc = Crc32Context.Data(output, (uint)realSize, out _);
|
||||
|
||||
if(crc != "3525ef06")
|
||||
throw new InvalidDataException("Incorrect decompressed checksum");
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Benchmarks.ods
BIN
Benchmarks.ods
Binary file not shown.
Reference in New Issue
Block a user