From 713dcd90837fcba422e2987bf7b5f210fda6d974 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 19 Jul 2018 11:45:55 +0900 Subject: [PATCH] #1921 --- src/server/api/call.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/server/api/call.ts b/src/server/api/call.ts index 769ff95ac..fa13deb6b 100644 --- a/src/server/api/call.ts +++ b/src/server/api/call.ts @@ -1,3 +1,4 @@ +import { performance } from 'perf_hooks'; import limitter from './limitter'; import { IUser } from '../../models/user'; import { IApp } from '../../models/app'; @@ -45,7 +46,13 @@ export default (endpoint: string, user: IUser, app: IApp, data: any, file?: any) // API invoking try { + const a = performance.now(); res = await exec(data, user, app); + const b = performance.now(); + + if (b - a > 500) { + console.warn(`SLOW API CALL DETECTED: ${ep.name}`); + } } catch (e) { rej(e); return;