From 2aa229d1451d1fde7d00414be63a3c1740a1f28d Mon Sep 17 00:00:00 2001 From: James Allen Date: Tue, 3 Feb 2015 11:05:23 +0000 Subject: [PATCH] Add in profiling end point --- services/web/app/coffee/infrastructure/Server.coffee | 9 +++++++++ services/web/package.json | 1 + 2 files changed, 10 insertions(+) diff --git a/services/web/app/coffee/infrastructure/Server.coffee b/services/web/app/coffee/infrastructure/Server.coffee index 9b92c3d2aa..635dff4c12 100644 --- a/services/web/app/coffee/infrastructure/Server.coffee +++ b/services/web/app/coffee/infrastructure/Server.coffee @@ -106,6 +106,15 @@ app.use (req, res, next) -> app.get "/status", (req, res)-> res.send("web sharelatex is alive") req.session.destroy() + +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 logger.info ("creating HTTP server").yellow server = require('http').createServer(app) diff --git a/services/web/package.json b/services/web/package.json index 77eb735781..5bce5af848 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -41,6 +41,7 @@ "translations-sharelatex": "git+https://github.com/sharelatex/translations-sharelatex.git#master", "underscore": "1.6.0", "underscore.string": "^3.0.2", + "v8-profiler": "^5.2.3", "xml2js": "0.2.0" }, "devDependencies": {