From 24dc31236708fa7d9b8885f9b71e58929769439b Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Sun, 11 Jul 2021 11:24:15 +0200 Subject: [PATCH] Add logs to benchmark --- apps/api/src/app/core/portfolio-calculator.ts | 8 ++++++-- apps/api/src/app/portfolio/portfolio.controller.ts | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/api/src/app/core/portfolio-calculator.ts b/apps/api/src/app/core/portfolio-calculator.ts index a730885a1..586101f59 100644 --- a/apps/api/src/app/core/portfolio-calculator.ts +++ b/apps/api/src/app/core/portfolio-calculator.ts @@ -167,11 +167,15 @@ export class PortfolioCalculator { timelinePeriodPromises.push(this.getTimePeriodForDate(j, currentDate)); } - const timelinePeriod: TimelinePeriod[] = await Promise.all( + console.time('calculate-timeline-periods'); + + const timelinePeriods: TimelinePeriod[] = await Promise.all( timelinePeriodPromises ); - return timelinePeriod; + console.timeEnd('calculate-timeline-periods'); + + return timelinePeriods; } private async getTimePeriodForDate(j: number, currentDate: Date) { diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 454f0c438..27976e709 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -90,6 +90,8 @@ export class PortfolioController { @Query('range') range, @Res() res: Response ): Promise { + console.time('get-chart-request'); + let chartData = await this.portfolioService.getChart( impersonationId, range @@ -130,6 +132,8 @@ export class PortfolioController { }); } + console.timeEnd('get-chart-request'); + return res.json(chartData); }