Skip to content

Commit eaa6ad7

Browse files
committed
fix(server): resource timings where off due to async functionality
1 parent 8e8fc8d commit eaa6ad7

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

server/src/services/movie/movie-service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class MovieService {
5454
options && Object.keys(options).length ? toQueryString(options) : '';
5555
const cacheName = `movie.${id}${optionsAsString}`;
5656
try {
57-
const start = Date.now();
57+
const start = performance.now();
5858
const result = await this.cacheProvider.wrap(
5959
cacheName,
6060
async () => {
@@ -109,10 +109,10 @@ export class MovieService {
109109
);
110110
return None;
111111
}
112-
const end = Date.now();
112+
const end = performance.now();
113113
this.logger.debug(
114114
{ movieId: id, name: result.title },
115-
`got movie details in ${end - start}ms`,
115+
`got movie details in ${Math.round(end - start)}ms`,
116116
);
117117
return Some(MovieEntity.create(result));
118118
} catch (error) {

server/src/services/person/person-service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class PersonService {
4545
options?: GetDetailsOptions,
4646
): Promise<Option<PersonEntity>> {
4747
try {
48-
const start = Date.now();
48+
const start = performance.now();
4949
const personResult = await this.personDetailsProvider.getDetails(id);
5050
if (!personResult.isOk()) {
5151
return None;
@@ -68,10 +68,10 @@ export class PersonService {
6868
),
6969
]);
7070
}
71-
const end = Date.now();
71+
const end = performance.now();
7272
this.logger.debug(
7373
{ personId: id, name: person.name },
74-
`got person details in ${end - start}ms`,
74+
`got person details in ${Math.round(end - start)}ms`,
7575
);
7676
return Some(person);
7777
} catch (error) {

server/src/services/show/show-service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class ShowService {
5454
options && Object.keys(options).length ? toQueryString(options) : '';
5555
const cacheName = `show.${id}${optionsAsString}`;
5656
try {
57-
const start = Date.now();
57+
const start = performance.now();
5858
const result = await this.cacheProvider.wrap<ShowProps | undefined>(
5959
cacheName,
6060
async () => {
@@ -109,10 +109,10 @@ export class ShowService {
109109
this.logger.debug({ showId: id }, 'show not found');
110110
return None;
111111
}
112-
const end = Date.now();
112+
const end = performance.now();
113113
this.logger.debug(
114114
{ showId: id, name: result.title, seasons: result.seasons.length },
115-
`got show details in ${end - start}ms`,
115+
`got show details in ${Math.round(end - start)}ms`,
116116
);
117117
return Some(ShowEntity.create(result));
118118
} catch (error) {

0 commit comments

Comments
 (0)