【问题标题】:Which is faster 'res.end(data)' or 'res.write(data);res.end()', why?'res.end(data)' 或 'res.write(data);res.end()' 哪个更快,为什么?
【发布时间】:2014-08-31 00:09:03
【问题描述】:

Here(click me) 是源代码。

我觉得它们的执行速度是一样的,都是需要判断的论据。

您对此有何看法?

【问题讨论】:

  • 请在问题中包含源代码。否则,如果链接发生变化,问题可能对其他人毫无用处。
  • 我在这里 0.0添加链接

标签: node.js http runtime node-modules


【解决方案1】:

res.end(data)ultimately calls res.write(data)。与服务器噪音相比,速度差异将是最小的,所以我会选择在语义上对您的应用程序更有意义的那个。

documentation confirms this

如果指定了data,则相当于调用response.write(data, encoding)后跟response.end()。

【讨论】:

    猜你喜欢
    • 2013-10-03
    • 1970-01-01
    • 1970-01-01
    • 2017-10-28
    • 2015-06-15
    • 2019-09-28
    • 2013-12-19
    • 1970-01-01
    • 2011-05-26
    相关资源
    最近更新 更多