-
Notifications
You must be signed in to change notification settings - Fork 272
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 benchmark for File.Move
#2437
base: main
Are you sure you want to change the base?
Conversation
@adamsitnik should we consider categorizing System.IO benchmarks by the filesystem they are running against? The results might differ a lot if the drive is NTFS, EXT4, EXFAT, etc., even within the same OS and .NET version. |
{ | ||
if (File.Exists(_moveDestination)) | ||
{ | ||
File.Delete(_moveDestination); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe File.Delete does not need protecting with File.Exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have taken the procedure from other methods in the class.
private string _moveSource; | ||
private string _moveDestination; | ||
|
||
[IterationSetup(Target = nameof(Move))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we try not to use IterationSetup if possible: https://github.com/dotnet/performance/blob/main/docs/microbenchmark-design-guidelines.md#iterationsetup
In case of move benchmark, we could just swap the files:
private ulong counter;
[Benchmark]
public void Move()
{
if (counter++ % 2 == 0)
File.Move(_moveSource, _moveDestination);
else
File.Move(_moveDestination, _moveSource);
}
@deeprobin do you plan to address feedback? |
This PR is used to introduce a benchmark to measure the performance of
File.Move
.See dotnet/runtime#65092
/cc @adamsitnik