2026-01-05 17:27:50 +00:00
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace SharpCompress.Performance;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Base class for all benchmarks providing common setup for test archives path
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class BenchmarkBase
|
|
|
|
|
{
|
|
|
|
|
protected readonly string TEST_ARCHIVES_PATH;
|
|
|
|
|
|
|
|
|
|
public BenchmarkBase()
|
|
|
|
|
{
|
|
|
|
|
var index = AppDomain.CurrentDomain.BaseDirectory.IndexOf(
|
|
|
|
|
"SharpCompress.Performance",
|
|
|
|
|
StringComparison.OrdinalIgnoreCase
|
|
|
|
|
);
|
2026-01-05 17:38:17 +00:00
|
|
|
|
|
|
|
|
if (index == -1)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException(
|
|
|
|
|
"Could not locate SharpCompress.Performance in the base directory path"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-05 17:27:50 +00:00
|
|
|
var path = AppDomain.CurrentDomain.BaseDirectory.Substring(0, index);
|
2026-01-05 17:36:08 +00:00
|
|
|
var solutionBasePath =
|
|
|
|
|
Path.GetDirectoryName(path)
|
|
|
|
|
?? throw new InvalidOperationException("Could not determine solution base path");
|
2026-01-05 17:27:50 +00:00
|
|
|
|
2026-01-05 17:36:08 +00:00
|
|
|
TEST_ARCHIVES_PATH = Path.Combine(solutionBasePath, "TestArchives", "Archives");
|
2026-01-05 17:27:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected string GetTestArchivePath(string filename) =>
|
|
|
|
|
Path.Combine(TEST_ARCHIVES_PATH, filename);
|
|
|
|
|
}
|