衡量js执行时间是一种告诉应用程序响应请求的速度的方式吗?

在我的node.js / express应用程序的开始,我有一个像microtime()函数的东西。

function microtime (get_as_float) { // Returns either a string or a float containing the current time in seconds and microseconds // // version: 1109.2015 // discuss at: http://phpjs.org/functions/microtime // + original by: Paulo Freitas // * example 1: timeStamp = microtime(true); // * results 1: timeStamp > 1000000000 && timeStamp < 2000000000 var now = new Date().getTime() / 1000; var s = parseInt(now, 10); return (get_as_float) ? now : (Math.round((now - s) * 1000) / 1000) + ' ' + s; } 

实际应用程序的代码如下所示:

 application.post('/', function(request, response) { t1 = microtime(true); //code //code response.send(something); console.log("Time elapsed: " + (microtime(true) - t1)); } 

耗时:0.00599980354309082

我的问题是,这是否意味着从POST请求到达服务器的时间到响应被发送出去的时间是〜0.005s?

我测量过客户端,但是我的networking速度很慢,所以我觉得有一些滞后与应用程序本身无关。 什么是快速简单的方法来检查请求被处理的速度有多快?

无耻的插在这里。 我已经编写了一个跟踪每个快速请求的时间使用情况的代理。

http://blog.notifymode.com/blog/2012/07/17/profiling-express-web-framwork-with-notifymode/

事实上,当我刚开始写代理时,我采取了同样的方法。 但是我很快意识到这是不准确的。 我的实现通过replaceExpress路由器来跟踪请求和响应之间的时间差。 这使我可以添加跟踪器function。 随意尝试一下。