-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test,v8: skip less and stabilize test-linux-perf.js
Co-authored-by: Matheus Marchini <mat@mmarchini.me> PR-URL: #27364 Refs: nodejs/build#1774 Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
- Loading branch information
Showing
2 changed files
with
61 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,17 @@ | ||
'use strict'; | ||
|
||
const crypto = require('crypto'); | ||
const { spawnSync } = require("child_process"); | ||
const sleepTime = new Number(process.argv[2] || "0.1"); | ||
const repeat = new Number(process.argv[3]) || 5; | ||
|
||
// 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 functionOne() { | ||
functionTwo(); | ||
} | ||
|
||
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"); | ||
} | ||
function functionTwo() { | ||
spawnSync('sleep', [`${sleepTime}`]); | ||
} | ||
|
||
for (let i = 0; i < 1000; i++) { | ||
functionOne(i); | ||
for (let i = 0; i < repeat; i++) { | ||
functionOne(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters