blob: 011ef19777bd3777c81c401561779b6f44f7f5a6 (
plain)
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
|
'use strict';
const crypto = require('crypto');
// Functions should be complex enough for V8 to run them a few times before
// compiling, but not complex enough to always stay in interpreted mode. They
// should also take some time to run, otherwise Linux perf might miss them
// entirely even when sampling at a high frequency.
function functionOne(i) {
for (let j=i; j > 0; j--) {
crypto.createHash('md5').update(functionTwo(i, j)).digest("hex");
}
}
function functionTwo(x, y) {
let data = ((((x * y) + (x / y)) * y) ** (x + 1)).toString();
if (x % 2 == 0) {
return crypto.createHash('md5').update(data.repeat((x % 100) + 1)).digest("hex");
} else {
return crypto.createHash('md5').update(data.repeat((y % 100) + 1)).digest("hex");
}
}
for (let i = 0; i < 1000; i++) {
functionOne(i);
}
|