-
Notifications
You must be signed in to change notification settings - Fork 0
test #6
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: master
Are you sure you want to change the base?
test #6
Conversation
yurii-litvinov
left a comment
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 void Main(string[] args) | ||
| { | ||
| var hash = MD5.CheckSum("C:\\Users\\89803\\Files\\MatMech\\Algebra"); |
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.
У меня такого нет, не работает :)
| Console.WriteLine("\n"); | ||
| hash = MD5.CheckSumMulti("C:\\Users\\89803\\Files\\MatMech\\Algebra"); | ||
| Console.WriteLine(hash); | ||
| } |
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.
А ещё по условию надо было время работы сравнить
|
|
||
| namespace Test2 | ||
| { | ||
| 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.
Надо комментарии
| public static string CheckSum(string path) | ||
| { | ||
| var dir = new DirectoryInfo(path); | ||
| var otherdir = dir.GetDirectories(); |
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.
otherDir
| { | ||
| var dir = new DirectoryInfo(path); | ||
| var otherdir = dir.GetDirectories(); | ||
| var files = dir.GetFiles(); |
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.
files в этом деле никак не участвуют, как я вижу
| string hash = BitConverter.ToString(md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(dir.Name))); | ||
| hash += MD5Multi(otherdir); | ||
| return hash; | ||
| } |
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 size = dir.GetFiles().Length < Environment.ProcessorCount | ||
| ? dir.GetFiles().Length | ||
| : Environment.ProcessorCount; |
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 size = dir.GetFiles().Length < Environment.ProcessorCount | ||
| ? dir.GetFiles().Length | ||
| : Environment.ProcessorCount; | ||
| var threads = new Thread[size]; |
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.
"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); | ||
| } | ||
| }); | ||
| } |
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.
Это самодельный плохой Parallel.ForEach :)
| { | ||
| for (var l = localI * chunkSize; l < (localI + 1) * chunkSize && l < files.Length; ++l) | ||
| { | ||
| hash += FileHash(files[l], 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.
Гонки тут всякие напридумывали... Конкатенируем строку и надеемся на русский авось
No description provided.