Skip to content

Commit

Permalink
refactor(@angular-devkit/build-angular): use high resolution time for…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
clydin committed Oct 7, 2022
1 parent bdbcd04 commit 212609e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function execute(
context: BuilderContext,
rebuildState?: RebuildState,
): Promise<ExecutionResult> {
const startTime = Date.now();
const startTime = process.hrtime.bigint();

const {
projectRoot,
Expand Down Expand Up @@ -206,7 +206,8 @@ async function execute(
}
}

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

return new ExecutionResult(true, codeResults.rebuild, codeBundleCache);
}
Expand Down

0 comments on commit 212609e

Please sign in to comment.