Conversation
yurii-litvinov
left a comment
There was a problem hiding this comment.
Тестов совсем нет
| { | ||
| static void Main(string[] args) | ||
| { | ||
| var hash = MD5.CheckSum("C:\\Users\\89803\\Files\\MatMech\\Algebra"); |
There was a problem hiding this comment.
У меня такого нет, не работает :)
| Console.WriteLine("\n"); | ||
| hash = MD5.CheckSumMulti("C:\\Users\\89803\\Files\\MatMech\\Algebra"); | ||
| Console.WriteLine(hash); | ||
| } |
There was a problem hiding this comment.
А ещё по условию надо было время работы сравнить
|
|
||
| namespace Test2 | ||
| { | ||
| public class MD5 |
| public static string CheckSum(string path) | ||
| { | ||
| var dir = new DirectoryInfo(path); | ||
| var otherdir = dir.GetDirectories(); |
| { | ||
| var dir = new DirectoryInfo(path); | ||
| var otherdir = dir.GetDirectories(); | ||
| var files = dir.GetFiles(); |
There was a problem hiding this comment.
files в этом деле никак не участвуют, как я вижу
| string hash = BitConverter.ToString(md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(dir.Name))); | ||
| hash += MD5Multi(otherdir); | ||
| return hash; | ||
| } |
There was a problem hiding this comment.
Если у нас папка с файлами, но без подпапок, получится не только неправда, но ещё и непараллельно совсем :)
| { | ||
| var size = dir.GetFiles().Length < Environment.ProcessorCount | ||
| ? dir.GetFiles().Length | ||
| : Environment.ProcessorCount; |
There was a problem hiding this comment.
Если в папке вообще нет файлов, этот код может оказаться в затруднительном положении
| var size = dir.GetFiles().Length < Environment.ProcessorCount | ||
| ? dir.GetFiles().Length | ||
| : Environment.ProcessorCount; | ||
| var threads = new Thread[size]; |
There was a problem hiding this comment.
"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.
Это самодельный плохой 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.
Гонки тут всякие напридумывали... Конкатенируем строку и надеемся на русский авось
No description provided.