@ms-cloudpack/task-reporter
Advanced tools
Comparing version 0.10.2 to 0.11.0
@@ -10,4 +10,5 @@ export { black, blue, bold, clearLine, cyan, darkGrey, gradient, green, grey, lightBlack, lightBlue, lightCyan, lightGreen, lightGrey, lightMagenta, lightRed, lightWhite, lightYellow, magenta, moveDownLines, moveUpLines, red, white, yellow, } from './ansiHelpers.js'; | ||
export { formatTime } from './formatTime.js'; | ||
export { formatMemoryString } from './formatMemoryString.js'; | ||
export { statusCharacter } from './statusCharacter.js'; | ||
export { table } from './table.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -74,2 +74,6 @@ import { TaskReporterTask, type TaskReporterTaskResult } from './TaskReporterTask.js'; | ||
/** | ||
* Show heap usage. | ||
*/ | ||
showHeapUsage?: boolean; | ||
/** | ||
* Show task details when a task completes. This is useful for showing | ||
@@ -100,2 +104,3 @@ * additional information about a task, such as the output of a command. | ||
private _ignoredLogMessages; | ||
private _maxHeapSize; | ||
constructor(options?: TaskReporterOptions); | ||
@@ -102,0 +107,0 @@ /** |
@@ -22,2 +22,3 @@ /// <reference types="node" /> | ||
forceShow?: boolean; | ||
heapDelta?: number; | ||
constructor(name: string); | ||
@@ -24,0 +25,0 @@ start(): void; |
@@ -18,2 +18,3 @@ /** | ||
showTaskExtended: false, | ||
showHeapUsage: false, | ||
}; | ||
@@ -41,2 +42,3 @@ /** | ||
showTaskDetails: true, | ||
showHeapUsage: true, | ||
}; | ||
@@ -43,0 +45,0 @@ /** |
@@ -10,4 +10,5 @@ export { black, blue, bold, clearLine, cyan, darkGrey, gradient, green, grey, lightBlack, lightBlue, lightCyan, lightGreen, lightGrey, lightMagenta, lightRed, lightWhite, lightYellow, magenta, moveDownLines, moveUpLines, red, white, yellow, } from './ansiHelpers.js'; | ||
export { formatTime } from './formatTime.js'; | ||
export { formatMemoryString } from './formatMemoryString.js'; | ||
export { statusCharacter } from './statusCharacter.js'; | ||
export { table } from './table.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -9,4 +9,5 @@ export { black, blue, bold, clearLine, cyan, darkGrey, gradient, green, grey, lightBlack, lightBlue, lightCyan, lightGreen, lightGrey, lightMagenta, lightRed, lightWhite, lightYellow, magenta, moveDownLines, moveUpLines, red, white, yellow, } from './ansiHelpers.js'; | ||
export { formatTime } from './formatTime.js'; | ||
export { formatMemoryString } from './formatMemoryString.js'; | ||
export { statusCharacter } from './statusCharacter.js'; | ||
export { table } from './table.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -74,2 +74,6 @@ import { TaskReporterTask, type TaskReporterTaskResult } from './TaskReporterTask.js'; | ||
/** | ||
* Show heap usage. | ||
*/ | ||
showHeapUsage?: boolean; | ||
/** | ||
* Show task details when a task completes. This is useful for showing | ||
@@ -100,2 +104,3 @@ * additional information about a task, such as the output of a command. | ||
private _ignoredLogMessages; | ||
private _maxHeapSize; | ||
constructor(options?: TaskReporterOptions); | ||
@@ -102,0 +107,0 @@ /** |
@@ -10,2 +10,4 @@ import { Writer } from './Writer.js'; | ||
import { statusCharacter } from './statusCharacter.js'; | ||
import { formatMemoryString } from './formatMemoryString.js'; | ||
import { bulletedList } from './index.js'; | ||
/** Controls how many tasks should be displayed in the pending sticky list. */ | ||
@@ -67,2 +69,3 @@ const maxRunningTasksShown = 5; | ||
this._hasCompleted = false; | ||
this._maxHeapSize = 0; | ||
// Catch console.log messages and print them using this.write. | ||
@@ -107,5 +110,7 @@ this._overrideConsoleLogging(); | ||
const task = new TaskReporterTask(name); | ||
let initialHeapSize = 0; | ||
task.on('start', () => { | ||
if (this._hasCompleted) | ||
return; | ||
initialHeapSize = process.memoryUsage().heapUsed; | ||
this._pendingTasks.delete(task); | ||
@@ -118,2 +123,3 @@ this._runningTasks.add(task); | ||
return; | ||
task.heapDelta = Math.max(0, process.memoryUsage().heapUsed - initialHeapSize); | ||
this._runningTasks.delete(task); | ||
@@ -242,2 +248,4 @@ this._completedTasks.push(task); | ||
_reportTaskComplete(task) { | ||
const memory = process.memoryUsage(); | ||
this._maxHeapSize = Math.max(this._maxHeapSize, memory.heapUsed); | ||
// Show completed tasks if the option is set, or if the task was forced to show. | ||
@@ -269,3 +277,3 @@ if (this._options.showCompleted || task.forceShow || (this._options.showErrors && task.status === 'fail')) { | ||
const summaryMessage = [ | ||
summary.complete && `${green(summary.complete)} tasks completed`, | ||
summary.complete && `${green(summary.complete)} task(s) completed`, | ||
summary.pass && `${green(summary.pass)} passed`, | ||
@@ -286,2 +294,13 @@ summary.fail && `${red(summary.fail)} failed`, | ||
} | ||
if (this._options.showHeapUsage) { | ||
this._maxHeapSize && this._writer.write(`\nMax heap size: ${green(formatMemoryString(this._maxHeapSize))}`); | ||
const tasksByUsage = this._completedTasks | ||
.filter((a) => !!a.heapDelta) | ||
.sort((a, b) => (b.heapDelta || 0) - (a.heapDelta || 0)) | ||
.slice(0, 10); | ||
if (tasksByUsage.length) { | ||
this._writer.write(`\nTop heap increments:\n`); | ||
this._writer.write(bulletedList(tasksByUsage.map((t) => `${t.name} (${formatMemoryString(t.heapDelta || 0)})`))); | ||
} | ||
} | ||
} | ||
@@ -292,9 +311,18 @@ _updateStickies() { | ||
} | ||
const totalTasks = this._completedTasks.length + this._pendingTasks.size + this._runningTasks.size; | ||
const percentage = totalTasks | ||
? ` (${green(`${Math.round((100 * this._completedTasks.length) / totalTasks)}%`)})` | ||
: ''; | ||
const memory = process.memoryUsage(); | ||
const heapUsage = `${green(formatMemoryString(memory.heapUsed))}`; | ||
const summaryStickies = [ | ||
'', | ||
`${darkGrey(`──┤`)} Waiting: ${yellow(this._pendingTasks.size)} ${darkGrey(`├──┤`)} Completed: ${green(this._completedTasks.length)} / ${green(totalTasks)}${percentage} ${darkGrey(`├──`)}`, | ||
[ | ||
darkGrey('['), | ||
[ | ||
this._runningTasks.size ? `Running: ${yellow(this._runningTasks.size)}` : 'Idle', | ||
this._pendingTasks.size && `Pending: ${yellow(this._pendingTasks.size)}`, | ||
this._completedTasks.length && `Completed: ${green(this._completedTasks.length)}`, | ||
this._options.showHeapUsage && `Heap: ${heapUsage}`, | ||
] | ||
.filter(Boolean) | ||
.join(darkGrey(` | `)), | ||
darkGrey(`]`), | ||
].join(' '), | ||
]; | ||
@@ -301,0 +329,0 @@ const runningTaskStickies = [ |
@@ -22,2 +22,3 @@ /// <reference types="node" resolution-mode="require"/> | ||
forceShow?: boolean; | ||
heapDelta?: number; | ||
constructor(name: string); | ||
@@ -24,0 +25,0 @@ start(): void; |
@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard. | ||
"packageName": "@microsoft/api-extractor", | ||
"packageVersion": "7.38.1" | ||
"packageVersion": "7.39.0" | ||
} | ||
] | ||
} |
{ | ||
"name": "@ms-cloudpack/task-reporter", | ||
"version": "0.10.2", | ||
"version": "0.11.0", | ||
"description": "Helpers for logging tasks to the console.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
269928
171
2506
1