Skip to content

Conversation

@MinyazevR
Copy link
Owner

No description provided.

@MinyazevR
Copy link
Owner Author

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

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

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

/// <summary>
/// Class representing the calculation of the check sum
/// </summary>
public class MD5

Choose a reason for hiding this comment

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

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

/// </summary>
public class MD5
{
public static async Task<byte[]> ComputeCheckSumForFile(string path)

Choose a reason for hiding this comment

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

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

/// Function for sequential calculation of the check sum of the directory
/// </summary>
/// <param name="pathToDirectory">Path to directory</param>
/// <returns></returns>

Choose a reason for hiding this comment

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

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

var directories = Directory.GetDirectories(pathToDirectory);
var list = new List<(byte[], string)>();

foreach(var directory in directories)

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 on lines +92 to +93
Parallel.ForEach(directories, directory => list.Add((ParallelComputeCheckSumForDirectory(directory), directory)));
Parallel.ForEach(files, file => list.Add((ParallelComputeCheckSumForDirectory(file), file)));

Choose a reason for hiding this comment

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

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

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


foreach (var (lol, bytes) in list)

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)

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)}");

Choose a reason for hiding this comment

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

:(

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

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