我可以像单元测试一样在 node.js 中进行性能测试吗
Can I get performance testing in node.js like a unit testing
我需要 nodejs 的性能 testing/tuning。
在 CI/CLI 中,就像一个单元测试。(目标是函数调用。不是网络。)
我现在用 mocha timeout()
。
var dictionary_handle;
it ("Dictionary.init_dictionary timeout", function(done) {
dictionary_handle = Dictionary.init_dictionary(dictionary_data);
done();
}).timeout(1000);
it ("Linad.initialize timeout", function(done) {
Linad.initialize(function(err){
done();
});
}).timeout(6000);
但这还不够
我需要那个功能。
- 可以在 CI 中使用。
- 执行多次
- 输出性能指标信息
我相信您正在寻找某种形式的 microbenchmark module. There is a number 选项,并且您的要求符合所有选项,因此我无法提出最佳人选,您需要进行自己的调查。
但是如果您添加了 performance-testing
标签,我可以给您一条通用的建议:当涉及到任何形式的性能测试时 - 您需要确保您的负载测试完全模拟您的应用程序测试现实生活中的使用情况。
如果您的被测应用程序是基于 NodeJS 的 Web 应用程序 - 除了单一功能性能之外,还有很多因素需要考虑,所以如果是这种情况,我建议考虑基于协议级别的负载测试工具,如果你想坚持 JavaScript 你可以使用像 k6 or consider another standalone free/open-source load testing solution 这样的东西,它可以模拟真实用户足够近,而你这边只需付出最小的努力。
Dmitri T 是正确的,您需要注意测试的内容和方式。话虽这么说,https://github.com/anywhichway/benchtest 几乎不需要对现有单元测试进行检测,因此它可能值得使用。
我需要 nodejs 的性能 testing/tuning。
在 CI/CLI 中,就像一个单元测试。(目标是函数调用。不是网络。)
我现在用 mocha timeout()
。
var dictionary_handle;
it ("Dictionary.init_dictionary timeout", function(done) {
dictionary_handle = Dictionary.init_dictionary(dictionary_data);
done();
}).timeout(1000);
it ("Linad.initialize timeout", function(done) {
Linad.initialize(function(err){
done();
});
}).timeout(6000);
但这还不够
我需要那个功能。
- 可以在 CI 中使用。
- 执行多次
- 输出性能指标信息
我相信您正在寻找某种形式的 microbenchmark module. There is a number 选项,并且您的要求符合所有选项,因此我无法提出最佳人选,您需要进行自己的调查。
但是如果您添加了 performance-testing
标签,我可以给您一条通用的建议:当涉及到任何形式的性能测试时 - 您需要确保您的负载测试完全模拟您的应用程序测试现实生活中的使用情况。
如果您的被测应用程序是基于 NodeJS 的 Web 应用程序 - 除了单一功能性能之外,还有很多因素需要考虑,所以如果是这种情况,我建议考虑基于协议级别的负载测试工具,如果你想坚持 JavaScript 你可以使用像 k6 or consider another standalone free/open-source load testing solution 这样的东西,它可以模拟真实用户足够近,而你这边只需付出最小的努力。
Dmitri T 是正确的,您需要注意测试的内容和方式。话虽这么说,https://github.com/anywhichway/benchtest 几乎不需要对现有单元测试进行检测,因此它可能值得使用。