JavaScript 包管理器基准测试
最后基准测试时间: 2024 年 4 月 21 日凌晨 2:44 (每天更新)。
此基准测试比较了 npm、pnpm、Yarn Classic 和 Yarn PnP 的性能(查看 Yarn 的基准测试 以了解此处未包含的任何其他 Yarn 模式)。
以下是对这些测试如何在现实世界中应用的简要说明
clean install: 执行完全全新安装所需的时间:没有 lockfile、缓存中没有包、没有node_modules文件夹。with cache,with lockfile,with node_modules: 完成第一次安装后,再次运行安装命令。with cache,with lockfile: 当开发人员获取一个仓库并首次运行安装时。with cache: 与上面相同,但包管理器没有 lockfile 可供使用。with lockfile: 当安装在 CI 服务器上运行时。with cache,with node_modules: 删除 lockfile 并再次运行安装命令。with node_modules,with lockfile: 删除包缓存并再次运行安装命令。with node_modules: 删除包缓存和 lockfile 并再次运行安装命令。update: 通过更改package.json中的版本并再次运行安装命令来更新依赖项。
大量文件
应用程序的 package.json 在这里
| 操作 | 缓存 | lockfile | node_modules | npm | pnpm | Yarn | Yarn PnP |
|---|---|---|---|---|---|---|---|
| 安装 | 31.3 秒 | 9.9 秒 | 7.3 秒 | 3.6 秒 | |||
| 安装 | ✔ | ✔ | ✔ | 1.5 秒 | 1 秒 | 5.2 秒 | n/a |
| 安装 | ✔ | ✔ | 8 秒 | 2.5 秒 | 5.4 秒 | 1.4 秒 | |
| 安装 | ✔ | 13.1 秒 | 6.4 秒 | 7.3 秒 | 3 秒 | ||
| 安装 | ✔ | 11.8 秒 | 6.2 秒 | 5.4 秒 | 1.4 秒 | ||
| 安装 | ✔ | ✔ | 1.7 秒 | 2.4 秒 | 6.9 秒 | n/a | |
| 安装 | ✔ | ✔ | 1.4 秒 | 1 秒 | 5.2 秒 | n/a | |
| 安装 | ✔ | 1.7 秒 | 6 秒 | 6.9 秒 | n/a | ||
| 更新 | n/a | n/a | n/a | 6.5 秒 | 3.7 秒 | 5.8 秒 | 3 秒 |