Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

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

Тестов совсем нет

{
static void Main(string[] args)
{
var hash = MD5.CheckSum("C:\\Users\\89803\\Files\\MatMech\\Algebra");
Copy link
Collaborator

Choose a reason for hiding this comment

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

У меня такого нет, не работает :)

Console.WriteLine("\n");
hash = MD5.CheckSumMulti("C:\\Users\\89803\\Files\\MatMech\\Algebra");
Console.WriteLine(hash);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

А ещё по условию надо было время работы сравнить


namespace Test2
{
public class MD5
Copy link
Collaborator

Choose a reason for hiding this comment

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

Надо комментарии

public static string CheckSum(string path)
{
var dir = new DirectoryInfo(path);
var otherdir = dir.GetDirectories();
Copy link
Collaborator

Choose a reason for hiding this comment

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

otherDir

{
var dir = new DirectoryInfo(path);
var otherdir = dir.GetDirectories();
var files = dir.GetFiles();
Copy link
Collaborator

Choose a reason for hiding this comment

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

files в этом деле никак не участвуют, как я вижу

string hash = BitConverter.ToString(md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(dir.Name)));
hash += MD5Multi(otherdir);
return hash;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Если у нас папка с файлами, но без подпапок, получится не только неправда, но ещё и непараллельно совсем :)

{
var size = dir.GetFiles().Length < Environment.ProcessorCount
? dir.GetFiles().Length
: Environment.ProcessorCount;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Если в папке вообще нет файлов, этот код может оказаться в затруднительном положении

var size = dir.GetFiles().Length < Environment.ProcessorCount
? dir.GetFiles().Length
: Environment.ProcessorCount;
var threads = new Thread[size];
Copy link
Collaborator

Choose a reason for hiding this comment

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

"As soon as you type new Thread() , it’s over; your project already has legacy code." (с) Concurrency in C# Cookbook

hash += FileHash(files[l], md5);
}
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Это самодельный плохой Parallel.ForEach :)

{
for (var l = localI * chunkSize; l < (localI + 1) * chunkSize && l < files.Length; ++l)
{
hash += FileHash(files[l], md5);
Copy link
Collaborator

@yurii-litvinov yurii-litvinov Dec 13, 2021

Choose a reason for hiding this comment

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

Гонки тут всякие напридумывали... Конкатенируем строку и надеемся на русский авось

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.

3 participants