md5 vs charCodeAt

Benchmark created on


Preparation HTML

<script src="https://cdn.jsdelivr.net/gh/emn178/js-md5/build/md5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/md5.min.js"></script>

Setup

const label = 'DimensionLabel';
const longLabel = 'VeryLongLabelVeryLongLabelVeryLongLabelVeryLongLabelVeryLongLabelVeryLongLabel';

const nativeCode = (label) => Array.from(label).reduce((acc, _, i) => acc + label.charCodeAt(i), 0)

Test runner

Ready to run.

Testing in
TestOps/sec
Native
nativeCode(label);
ready
Native (long)
nativeCode(longLabel);
ready
md5
md5(label);
ready
md5 (long)
md5(longLabel);
ready
CryptoJS
CryptoJS.MD5(label).toString();
ready
CryptoJS (long)
CryptoJS.MD5(longLabel).toString();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.