From 9ee2706410ca1446e960bc574fd7c0c44ecb8252 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 16 Mar 2015 15:02:45 +0000 Subject: [PATCH] add v8 profiler on /profile?time=MS url --- services/clsi/app.coffee | 9 +++++++++ services/clsi/package.json | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/services/clsi/app.coffee b/services/clsi/app.coffee index 9ac1d1dc18..78fad79b41 100644 --- a/services/clsi/app.coffee +++ b/services/clsi/app.coffee @@ -86,6 +86,15 @@ app.get "/health_check", (req, res)-> res.contentType(resCacher?.setContentType) res.send resCacher?.code, resCacher?.body +profiler = require "v8-profiler" +app.get "/profile", (req, res) -> + time = parseInt(req.query.time || "1000") + profiler.startProfiling("test") + setTimeout () -> + profile = profiler.stopProfiling("test") + res.json(profile) + , time + app.use (error, req, res, next) -> logger.error err: error, "server error" res.send error?.statusCode || 500 diff --git a/services/clsi/package.json b/services/clsi/package.json index 678d97123a..97bd5ae9db 100644 --- a/services/clsi/package.json +++ b/services/clsi/package.json @@ -23,7 +23,8 @@ "express": "^4.2.0", "body-parser": "^1.2.0", "fs-extra": "^0.16.3", - "underscore": "^1.8.2" + "underscore": "^1.8.2", + "v8-profiler": "^5.2.4" }, "devDependencies": { "mocha": "1.10.0",