Fix path validation and add iteration cleanup to prevent file reuse

Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-05 17:38:17 +00:00
parent e519f61f0f
commit a92ce90252
2 changed files with 21 additions and 0 deletions

View File

@@ -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)

View File

@@ -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()
{