Created
September 27, 2024 19:52
-
-
Save KevLehman/084c74a46a3b66c745ad2c5bbff9a082 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const data = require('./2mfKxOI9iPDobZFHAXL7uMgyg9i.json') | |
function getExecDiffInSecs(start, end) { | |
return (new Date(end) - new Date(start)) / 1000 / 60; | |
} | |
function printOverallExecTime() { | |
const total = getExecDiffInSecs(data.execution.startTime, data.execution.endTime); | |
console.log(`TOTAL TIME: ${total}m`); | |
} | |
function processServiceAndDependantTimes() { | |
const serviceMap = new Map(); | |
data.tasks.forEach((t) => { | |
serviceMap.set(t.taskId, { | |
dependants: t.dependencies, | |
taskTotalTimeInSecs: getExecDiffInSecs(t.execution.startTime, t.execution.endTime), | |
dependantTimes: new Map(), | |
}) | |
}); | |
serviceMap.forEach((service) => { | |
if (service.dependants.length === 0) { | |
return service; | |
} | |
service.dependants.forEach((dependencyId) => { | |
const task = serviceMap.get(dependencyId); | |
if (!task) { | |
service.dependantTimes.set(dependencyId, 0); | |
return; | |
} | |
service.dependantTimes.set(dependencyId, task.taskTotalTimeInSecs); | |
}); | |
}); | |
serviceMap.forEach((service, name) => { | |
console.log(` | |
Service ${name} | |
Depends on: ${service.dependants.join(', ') || 'Nothing'} | |
Total Exec time: ${service.taskTotalTimeInSecs} | |
----------------------------------------------- | |
`) | |
service.dependants.length && console.table(service.dependantTimes) | |
}) | |
} | |
function processData() { | |
printOverallExecTime(); | |
processServiceAndDependantTimes(); | |
} | |
processData() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment