-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
// test.js
const iterations = 10; // Number of iterations
function performTask(iteration) {
// Simulate some asynchronous task
setTimeout(() => {
const end = process.hrtime();
const executionTime = end[0] * 1000 + end[1] / 1000000; // Convert to milliseconds
console.log(`Iteration ${iteration} took ${executionTime.toFixed(2)} ms`);
}, Math.random() * 1000); // Simulate variable execution time
}
for (let i = 0; i < iterations; i++) {
const start = process.hrtime();
performTask(i);
const end = process.hrtime();
const executionTime = end[0] * 1000 + end[1] / 1000000; // Convert to milliseconds
console.log(`Scheduling iteration ${i} took ${executionTime.toFixed(2)} ms`);
}
console.log('All iterations scheduled.');
Metadata
Metadata
Assignees
Labels
No labels