Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmarks for ZipFile.CreateFromDirectory and ZipFile.ExtractToDirectory #4764

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

carlossanlop
Copy link
Member

Also added a test zip file containing the files inside the existing TestData folder.

Will soon use this class for the async versions of these methods.

Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlossanlop thank you for providing more benchmarks! PTAL at my comments.

Comment on lines +37 to +38

public void ZipFileExtractToDirectory()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was that supposed to be a benchmark too?

Suggested change
public void ZipFileExtractToDirectory()
[Benchmark]
public void ZipFileExtractToDirectory()

private static readonly string _testInputZipFile = Path.Combine(
AppContext.BaseDirectory, "libraries", "System.IO.Compression", "TestInputZipFile.zip");

[IterationSetup(Target = nameof(ZipFileCreateFromDirectory))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long does it take to run this benchmark? We usually avoid [IterationSetup] for the reasons described here:

https://github.com/dotnet/performance/blob/main/docs/microbenchmark-design-guidelines.md#iterationsetup

Does ZipFile.CreateFromDirectory overwrite the file?

@@ -118,6 +118,9 @@
<None Update="libraries\System.IO.Compression\TestData\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="libraries\System.IO.Compression\TestZipFile.zip">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about suggesting to just zip TestData during [GlobalSetup] but then I've realized that if somebody adds new file to TestData, the time reported by the benchmark is going to report a regression.

So please keep the zip file. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants