Skip to content

Commit

Permalink
feat: Monitor memory consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer committed May 27, 2024
1 parent 59a1590 commit 2f0b214
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/lib/Pipeline.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import path from 'node:path';
import * as fs from 'node:fs';
import {isFilePathString, isTriplyDBPathString} from '../utils/guards.js';
import TriplyDB from './TriplyDB.class.js';
import prettyMilliseconds from 'pretty-ms';
import {memoryConsumption} from '../utils/memory.js';
interface PipelineOptions {
startFromStageName?: string;
silent?: boolean;
Expand Down Expand Up @@ -191,7 +193,10 @@ class Pipeline {
iterationsProcessed
)}\n Generated quads: ${millify(
quadsGenerated
)}\n Duration: ${formatDuration(startTime, performance.now())} `;
)}\n Duration: ${formatDuration(
startTime,
performance.now()
)}\n Memory: ${memoryConsumption()} MB`;
});
stage.on('error', e => {
spinner.fail();
Expand Down Expand Up @@ -229,10 +234,9 @@ class Pipeline {
chalk.green(
`✔ your pipeline "${chalk.bold(
this.name
)}" was completed in ${formatDuration(
this.startTime,
performance.now()
)}`
)}" was completed in ${prettyMilliseconds(
performance.now() - this.startTime
)} using ${memoryConsumption()} MB of memory.`
)
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/utils/memory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const memoryConsumption = () =>
Math.round(process.memoryUsage().heapUsed / 1024 / 1024);

0 comments on commit 2f0b214

Please sign in to comment.