Skip to content

Commit 212609e

Browse files
committed
refactor(@angular-devkit/build-angular): use high resolution time for esbuild builder completion time
Update the build time calculation for the experimental esbuild-based browser application builder to use the `process.hrtime` time source. The high resolution time provides a more accurate time source and allows for nanosecond level timings if needed. Currently the console output is rounded to the nearest millisecond. Future performance monitoring capabilities may leverage the more fine-grained values.
1 parent bdbcd04 commit 212609e

File tree

1 file changed

+3
-2
lines changed
  • packages/angular_devkit/build_angular/src/builders/browser-esbuild

1 file changed

+3
-2
lines changed

packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async function execute(
6969
context: BuilderContext,
7070
rebuildState?: RebuildState,
7171
): Promise<ExecutionResult> {
72-
const startTime = Date.now();
72+
const startTime = process.hrtime.bigint();
7373

7474
const {
7575
projectRoot,
@@ -206,7 +206,8 @@ async function execute(
206206
}
207207
}
208208

209-
context.logger.info(`Complete. [${(Date.now() - startTime) / 1000} seconds]`);
209+
const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
210+
context.logger.info(`Complete. [${buildTime.toFixed(3)} seconds]`);
210211

211212
return new ExecutionResult(true, codeResults.rebuild, codeBundleCache);
212213
}

0 commit comments

Comments
 (0)