forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
md4-cache.js
39 lines (36 loc) · 900 Bytes
/
md4-cache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const createHash = require("../lib/util/createHash");
const compare = require("./micro-compare");
const size = 50;
const strings = [];
for (let count = 1; ; count *= 10) {
while (strings.length < count) {
const s = require("crypto").randomBytes(size).toString("hex");
strings.push(s);
const hash = createHash("native-md4");
hash.update(s);
hash.update(s);
hash.digest("hex");
}
let i = 0;
console.log(
`${count} different 200 char strings: ` +
compare(
"native md4",
() => {
const hash = createHash("native-md4");
const s = strings[(i = (i + 1) % strings.length)];
hash.update(s);
hash.update(s);
return hash.digest("hex");
},
"wasm md4",
() => {
const hash = createHash("md4");
const s = strings[(i = (i + 1) % strings.length)];
hash.update(s);
hash.update(s);
return hash.digest("hex");
}
)
);
}