cloud-profiler-nodejs
cloud-profiler-nodejs copied to clipboard
setTimeout is attributed to the file in which it is called.

This is the script used (it's what we use in our prober), but I saw the same thing happening when I was experimenting with getting accurate line numbers:
var profiler = require('@google-cloud/profiler').start({
serviceContext: {
service: 'service',
version: 'version',
},
});
const startTime = Date.now();
const testArr = [];
function nodeJSLoop(durationSeconds) {
for (let i = 0; i < testArr.length; i++) {
for (let j = 0; j < testArr[i].length; j++) {
testArr[i][j] = Math.sqrt(j * testArr[i][j]);
}
}
if (Date.now() - startTime < 1000 * durationSeconds) {
setTimeout(() => nodeJSLoop(durationSeconds), 5);
}
}
function nodeJSBench(durationSeconds) {
// Allocate 16 MiB in 64 KiB chunks.
for (let i = 0; i < 16*16; i++) {
testArr[i] = new Array(64 * 1024);
}
nodeJSLoop(durationSeconds)
}
@psmarshall -- is this be expected?
Is the expected result that it shows up in node/lib/timers.js where this is implemented?
Yes, I think I would expect it's file to be timer.js (it's parent is indicated as being in "timer.js"). Should have clarified, so thanks!