mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-23 15:34:34 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user