3 ms·
Just for giggles I tried this and I'm getting ~200ms when reading and hashing 50MB file in the browser (Chromium based) vs ~120ms using Python 3.11.6. https://
by frankjr 3y ago
Just for giggles I tried this and I'm getting ~200ms when reading and hashing 50MB file in the browser (Chromium based) vs ~120ms using Python 3.11.6.
https://jsfiddle.net/yebdnz6x/ https://jsfiddle.net/yebdnz6x/
- JodieBenitez 3y agoNot so bad compared to what I tried a few years ago. Might finally be usable for us...
- jampekka 3y agoAll major browsers have supported it for over eight years. Maybe the problem was between the seat and the keyboard? https://caniuse.com/mdn-api_crypto_subtle https://caniuse.com/mdn-api_crypto_subtle
- JodieBenitez 3y agoMaybe 8 years is not much in a career ? Maybe we had to support one of those browsers that did not support it ? Maybe your snarky comment is out of place ? And even to this day it's still significantly slower than Python stdlib according to the tester. So much for "why python not as fast as js, python is slow, blah blah blah".
- ptx 3y agoI thought that perhaps the difference could be due to the JavaScript version having to first read the entire file before getting started on hashing it , whereas the Python does it incrementally (which the browser API doesn't support [0]). But changing the Python version to work like the JavaScript version doesn't make a big difference: 30 vs 35 ms (with a ~50 MB file) on my machine. The slowest part in the JavaScript version seems to be reading the file, accounting for 70–80% of the runtime in both Firefox and Chromium. [0] https://github.com/w3c/webcrypto/issues/73 https://github.com/w3c/webcrypto/issues/73