MCPcopy Index your code
hub / github.com/nodejs/node / getProgress

Method getProgress

benchmark/_benchmark_progress.js:76–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74 }
75
76 getProgress() {
77 // Get time as soon as possible.
78 const diff = process.hrtime(this.startTime);
79
80 const completedRuns = this.completedRuns;
81 const scheduledRuns = this.scheduledRuns;
82 const finished = completedRuns === scheduledRuns;
83
84 // Calculate numbers for fractions.
85 const runsPerFile = this.runsPerFile;
86 const completedFiles = Math.floor(completedRuns / runsPerFile);
87 const scheduledFiles = this.benchmarks.length;
88 const completedRunsForFile =
89 finished ? runsPerFile : completedRuns % runsPerFile;
90 const completedConfig = this.completedConfig;
91 const scheduledConfig = this.scheduledConfig;
92
93 // Calculate the percentage.
94 let runRate = 0; // Rate of current incomplete run.
95 if (completedConfig !== scheduledConfig) {
96 runRate = completedConfig / scheduledConfig;
97 }
98 const completedRate = ((completedRuns + runRate) / scheduledRuns);
99 const percent = pad(Math.floor(completedRate * 100), 3, ' ');
100
101 const caption = finished ? 'Done\n' : this.currentFile;
102 return `[${getTime(diff)}|% ${percent}| ` +
103 `${fraction(completedFiles, scheduledFiles)} files | ` +
104 `${fraction(completedRunsForFile, runsPerFile)} runs | ` +
105 `${fraction(completedConfig, scheduledConfig)} configs]: ` +
106 `${caption} `;
107 }
108
109 updateProgress() {
110 if (!process.stderr.isTTY || process.stdout.isTTY) {

Callers 1

updateProgressMethod · 0.95

Calls 3

getTimeFunction · 0.85
fractionFunction · 0.85
padFunction · 0.70

Tested by

no test coverage detected