/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v16.2.12
bench/recursive-delete/nodejs-rm.js
27 строк
806 B
Benjamin Woodruff
test: Fix and update recursive-delete benchmarks (#84875)
21 окт 2025, 03:52
Не верифицирован
21 окт 2025, 03:52
b3959cd
Код
Авторство
О чём код?
import { rm as rmPromises } from 'fs/promises' import { rm as rmCallback, rmSync } from 'fs' import { promisify } from 'util' const rmCallbackPromise = promisify(rmCallback) const targetDir = process.argv[2] const method = process.argv[3] // 'promises', 'callback', or 'sync' async function test() { const time = process.hrtime() if (method === 'promises') { await rmPromises(targetDir, { recursive: true, force: true }) } else if (method === 'callback') { await rmCallbackPromise(targetDir, { recursive: true, force: true }) } else if (method === 'sync') { rmSync(targetDir, { recursive: true, force: true }) } const hrtime = process.hrtime(time) const nanoseconds = hrtime[0] * 1e9 + hrtime[1] const milliseconds = nanoseconds / 1e6 console.log(milliseconds) } test()