diff --git a/tests/SharpCompress.Performance/BenchmarkBase.cs b/tests/SharpCompress.Performance/BenchmarkBase.cs index 55b66f5a..6d9c3388 100644 --- a/tests/SharpCompress.Performance/BenchmarkBase.cs +++ b/tests/SharpCompress.Performance/BenchmarkBase.cs @@ -16,6 +16,14 @@ public class BenchmarkBase "SharpCompress.Performance", StringComparison.OrdinalIgnoreCase ); + + if (index == -1) + { + throw new InvalidOperationException( + "Could not locate SharpCompress.Performance in the base directory path" + ); + } + var path = AppDomain.CurrentDomain.BaseDirectory.Substring(0, index); var solutionBasePath = Path.GetDirectoryName(path) diff --git a/tests/SharpCompress.Performance/WriteBenchmarks.cs b/tests/SharpCompress.Performance/WriteBenchmarks.cs index 95c31cdb..02c69a36 100644 --- a/tests/SharpCompress.Performance/WriteBenchmarks.cs +++ b/tests/SharpCompress.Performance/WriteBenchmarks.cs @@ -34,6 +34,19 @@ public class WriteBenchmarks : BenchmarkBase } } + [IterationCleanup] + public void IterationCleanup() + { + // Clean up created archives after each iteration to avoid file reuse affecting measurements + if (Directory.Exists(_tempOutputPath)) + { + foreach (var file in Directory.GetFiles(_tempOutputPath)) + { + File.Delete(file); + } + } + } + [GlobalCleanup] public void Cleanup() {