mirror of
https://github.com/aaru-dps/AaruBenchmark.git
synced 2025-12-16 19:24:36 +00:00
Add bzip2.
This commit is contained in:
@@ -62,6 +62,9 @@ namespace AaruBenchmark
|
||||
|
||||
[Benchmark]
|
||||
public void DotNetZip() => Compression.DotNetZip.Bzip2();
|
||||
|
||||
[Benchmark]
|
||||
public void AaruNative() => Compression.AaruNative.Bzip2();
|
||||
}
|
||||
|
||||
[SimpleJob(RuntimeMoniker.Net60)]
|
||||
|
||||
@@ -12,6 +12,10 @@ namespace AaruBenchmark.Compression
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
static extern int adc_decode_buffer(byte[] dst_buffer, int dst_size, byte[] src_buffer, int src_size);
|
||||
|
||||
[DllImport("libAaru.Compression.Native", SetLastError = true)]
|
||||
static extern int BZ2_bzBuffToBuffDecompress(byte[] dest, ref uint destLen, byte[] source, uint sourceLen,
|
||||
int small, int verbosity);
|
||||
|
||||
public static void AppleRle()
|
||||
{
|
||||
const int bufferSize = 32768;
|
||||
@@ -59,5 +63,30 @@ namespace AaruBenchmark.Compression
|
||||
if(crc != "5a5a7388")
|
||||
throw new InvalidDataException("Incorrect decompressed checksum");
|
||||
}
|
||||
|
||||
public static void Bzip2()
|
||||
{
|
||||
const int bufferSize = 1048576;
|
||||
byte[] input = new byte[1053934];
|
||||
|
||||
var fs = new FileStream(Path.Combine(Program.Folder, "bzip2.bz2"), FileMode.Open, FileAccess.Read);
|
||||
|
||||
fs.Read(input, 0, input.Length);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
|
||||
byte[] output = new byte[bufferSize];
|
||||
|
||||
uint realSize = (uint)output.Length;
|
||||
int bzError = BZ2_bzBuffToBuffDecompress(output, ref realSize, input, (uint)input.Length, 0, 0);
|
||||
|
||||
if(realSize != 1048576)
|
||||
throw new InvalidDataException("Incorrect decompressed size");
|
||||
|
||||
string crc = Crc32Context.Data(output, realSize, out _);
|
||||
|
||||
if(crc != "c64059c0")
|
||||
throw new InvalidDataException("Incorrect decompressed checksum");
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Benchmarks.ods
BIN
Benchmarks.ods
Binary file not shown.
Reference in New Issue
Block a user