Skip to Content

性能基准测试

性能测试很重要,如果你想衡量一个变更如何影响你应用程序的性能。我们提供了一种简单的方式来从用户和贡献者的角度对你的应用进行性能测试。该设置允许你在不同的分支上以及在不同版本的 Node.js 上自动化性能测试。

我们将使用的模块:

简单

在当前分支中运行测试

npm run benchmark

对不同的 Node.js 版本进行测试 ✨

npx -p node@10 -- npm run benchmark

高级

在不同分支上运行测试

branchcmp --rounds 2 --script "npm run benchmark"

在不同分支和不同的 Node.js 版本上进行测试 ✨

branchcmp --rounds 2 --script "npm run benchmark"

将当前分支与主分支(Gitflow)比较

branchcmp --rounds 2 --gitflow --script "npm run benchmark"

npm run bench

运行不同的示例

branchcmp --rounds 2 -s "node ./node_modules/concurrently -k -s first \"node ./examples/asyncawait.js\" \"node ./node_modules/autocannon -c 100 -d 5 -p 10 localhost:3000/\""