Skip to content

Test#5

Open
MinyazevR wants to merge 3 commits intomainfrom
Test
Open

Test#5
MinyazevR wants to merge 3 commits intomainfrom
Test

Conversation

@MinyazevR
Copy link
Copy Markdown
Owner

No description provided.

@MinyazevR
Copy link
Copy Markdown
Owner Author

Понял свою ошибку, я сортировал не имена файлов а список состоящий из пар (byte[], имя файла)

Comment on lines +5 to +8
[SetUp]
public void Setup()
{
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
[SetUp]
public void Setup()
{
}

Comment thread Test/Test/Test/MD5.cs
/// <summary>
/// Class representing the calculation of the check sum
/// </summary>
public class MD5
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Все методы static, следовательно и сам класс мог бы быть static

Comment thread Test/Test/Test/MD5.cs
/// </summary>
public class MD5
{
public static async Task<byte[]> ComputeCheckSumForFile(string path)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

А тут комментария не хватает. И я бы его и методы ниже сделал private — не пользователь должен решать, файл у нас или папка. Я как пользователь хочу просто передать путь и получить хеш, думать не хочу.

Comment thread Test/Test/Test/MD5.cs
/// Function for sequential calculation of the check sum of the directory
/// </summary>
/// <param name="pathToDirectory">Path to directory</param>
/// <returns></returns>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Пустые тэги не нужны

Comment thread Test/Test/Test/MD5.cs
var directories = Directory.GetDirectories(pathToDirectory);
var list = new List<(byte[], string)>();

foreach(var directory in directories)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
foreach(var directory in directories)
foreach (var directory in directories)

Comment thread Test/Test/Test/MD5.cs
Comment on lines +92 to +93
Parallel.ForEach(directories, directory => list.Add((ParallelComputeCheckSumForDirectory(directory), directory)));
Parallel.ForEach(files, file => list.Add((ParallelComputeCheckSumForDirectory(file), file)));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Вы не верите в гонки? :)

Comment thread Test/Test/Test/MD5.cs
Comment on lines +99 to +102
var directoryName = System.Text.Encoding.UTF8.GetBytes(Path.GetDirectoryName(pathToDirectory)!);


foreach (var (lol, bytes) in list)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
var directoryName = System.Text.Encoding.UTF8.GetBytes(Path.GetDirectoryName(pathToDirectory)!);
foreach (var (lol, bytes) in list)
var directoryName = System.Text.Encoding.UTF8.GetBytes(Path.GetDirectoryName(pathToDirectory)!);
foreach (var (lol, bytes) in list)

Comment on lines +7 to +10
}


static (IEnumerable<long>, IEnumerable<long>) Calculate(string path)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
}
static (IEnumerable<long>, IEnumerable<long>) Calculate(string path)
}
static (IEnumerable<long>, IEnumerable<long>) Calculate(string path)

Comment on lines +41 to +42
//stream.WriteLine();
//stream.Write($"{size} {Math.Round(averageForStandardCalculations, 3)} {Math.Round(Math.Sqrt(varianceForStandardCalculations), 3)} {Math.Round(averageForParallelCalculations, 3)} {Math.Round(Math.Sqrt(varianceForParallelCalculations), 3)}");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

:(

Comment thread Test/Test/Test/MD5.cs
// После просто Task.Run(() => {...}) и объединять Task.Result
// Но так вроде выглядит проще
Parallel.ForEach(directories, directory => list.Add((ParallelComputeCheckSumForDirectory(directory), directory)));
Parallel.ForEach(files, file => list.Add((ParallelComputeCheckSumForDirectory(file), file)));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

И ComputeCheckSumForFile тут. Как тестировали, оно же падает сразу? :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants