-
Notifications
You must be signed in to change notification settings - Fork 0
Test #5
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
base: main
Are you sure you want to change the base?
Conversation
|
Понял свою ошибку, я сортировал не имена файлов а список состоящий из пар (byte[], имя файла) |
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| } |
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.
| [SetUp] | |
| public void Setup() | |
| { | |
| } |
| /// <summary> | ||
| /// Class representing the calculation of the check sum | ||
| /// </summary> | ||
| public class MD5 |
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.
Все методы static, следовательно и сам класс мог бы быть static
| /// </summary> | ||
| public class MD5 | ||
| { | ||
| public static async Task<byte[]> ComputeCheckSumForFile(string path) |
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.
А тут комментария не хватает. И я бы его и методы ниже сделал private — не пользователь должен решать, файл у нас или папка. Я как пользователь хочу просто передать путь и получить хеш, думать не хочу.
| /// Function for sequential calculation of the check sum of the directory | ||
| /// </summary> | ||
| /// <param name="pathToDirectory">Path to directory</param> | ||
| /// <returns></returns> |
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.
Пустые тэги не нужны
| var directories = Directory.GetDirectories(pathToDirectory); | ||
| var list = new List<(byte[], string)>(); | ||
|
|
||
| foreach(var directory in directories) |
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.
| foreach(var directory in directories) | |
| foreach (var directory in directories) |
| Parallel.ForEach(directories, directory => list.Add((ParallelComputeCheckSumForDirectory(directory), directory))); | ||
| Parallel.ForEach(files, file => list.Add((ParallelComputeCheckSumForDirectory(file), file))); |
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.
Вы не верите в гонки? :)
| var directoryName = System.Text.Encoding.UTF8.GetBytes(Path.GetDirectoryName(pathToDirectory)!); | ||
|
|
||
|
|
||
| foreach (var (lol, bytes) in list) |
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.
| 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) |
| } | ||
|
|
||
|
|
||
| static (IEnumerable<long>, IEnumerable<long>) Calculate(string path) |
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.
| } | |
| static (IEnumerable<long>, IEnumerable<long>) Calculate(string path) | |
| } | |
| static (IEnumerable<long>, IEnumerable<long>) Calculate(string path) |
| //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)}"); |
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.
:(
| // После просто Task.Run(() => {...}) и объединять Task.Result | ||
| // Но так вроде выглядит проще | ||
| Parallel.ForEach(directories, directory => list.Add((ParallelComputeCheckSumForDirectory(directory), directory))); | ||
| Parallel.ForEach(files, file => list.Add((ParallelComputeCheckSumForDirectory(file), file))); |
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.
И ComputeCheckSumForFile тут. Как тестировали, оно же падает сразу? :)
No description provided.