-   Notifications  
You must be signed in to change notification settings  - Fork 34
 
Description
Originally opened as dart-lang/sdk#4611
This issue was originally filed by dha...@google.com
Test code:
 new File('recordroyale.ogg').readAsBytes().then((buf) {
   var md5 = new MD5();
   md5.update(buf);
   print(md5.digest());
 });
where 'recordroyale.ogg' is about six megabytes. This takes 22 seconds on my machine. Shelling out to md5sum(1) takes under 0.02 seconds. I understand that Dart won't ever be as fast as C, but with this disparity, the hash algorithms should be implemented in C[++] rather than Dart.
I had a vague suspicion that this was slow due to unnecessary allocations, but the allocations are mostly small and consumed quickly. Refactoring to eliminate unnecessary allocations resulted in no change.
My use case involved checksumming a byte array that existed only in memory at the relevant location; it is far less convenient to write data to a temporary file, shell out to md5sum(1), then delete that file.