| 20 | } |
| 21 | |
| 22 | async function run(fn) { |
| 23 | async function test() { |
| 24 | const start = process.hrtime() |
| 25 | |
| 26 | await fn(srcDir, destDir) |
| 27 | |
| 28 | const timer = process.hrtime(start) |
| 29 | const ms = (timer[0] * 1e9 + timer[1]) / 1e6 |
| 30 | return ms |
| 31 | } |
| 32 | |
| 33 | const ts = [] |
| 34 | |
| 35 | for (let i = 0; i < 10; i++) { |
| 36 | const t = await test() |
| 37 | await remove(destDir) |
| 38 | ts.push(t) |
| 39 | } |
| 40 | |
| 41 | const sum = ts.reduce((a, b) => a + b) |
| 42 | const nb = ts.length |
| 43 | const avg = sum / nb |
| 44 | console.log({ sum, nb, avg }) |
| 45 | } |
| 46 | |
| 47 | async function main() { |
| 48 | await createSrcFolder() |