diff --git a/next/api/src/controller/translate.ts b/next/api/src/controller/translate.ts index e2ad9b62c..ca9011c5a 100644 --- a/next/api/src/controller/translate.ts +++ b/next/api/src/controller/translate.ts @@ -14,10 +14,18 @@ export class TranslateController { async translate( @Body(new ZodValidationPipe(translateSchema)) { text }: z.infer ) { - const result = await translateService.translate(text); - if (!result) { - throw new HttpError(400, 'translation service is not configured'); + const start = performance.now(); + let translateResult; + try{ + translateResult = await translateService.translate(text); + } finally { + const end = performance.now(); + console.log(`translate ${text} cost ${end - start}ms, result: ${translateResult?.from}, ${translateResult?.text}`); } - return result; + + if (!translateResult) { + throw new HttpError(400, 'translation service is not available'); + } + return translateResult; } }