babakfp
babakfp•10mo ago

Trying to benchmark `Deno.remove` but it fails

deno bench --allow-write bench.ts
Check file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts
cpu: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
runtime: deno 1.36.4 (x86_64-pc-windows-msvc)

file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts
Deno.remove error: NotFound: The system cannot find the file specified. (os error 2): remove './assets'
await Deno.remove("./assets", { recursive: true })
^
at async Object.remove (ext:deno_fs/30_fs.js:201:3)
at async file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts:2:5
error: Bench failed
deno bench --allow-write bench.ts
Check file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts
cpu: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
runtime: deno 1.36.4 (x86_64-pc-windows-msvc)

file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts
Deno.remove error: NotFound: The system cannot find the file specified. (os error 2): remove './assets'
await Deno.remove("./assets", { recursive: true })
^
at async Object.remove (ext:deno_fs/30_fs.js:201:3)
at async file:///C:/Users/babak/OneDrive/Desktop/deno-benchmark-345654/bench.ts:2:5
error: Bench failed
6 Replies
ioB
ioB•10mo ago
The benchmark runs the code several times In this case, it ran it once, deleted the folder, and ran it again and found no folder to delete You need to re-add the folder every time
babakfp
babakfp•10mo ago
Aha Thanks for that. Is there a way to tell it to run only once?
NDH
NDH•10mo ago
just use performance.now() for single test
ioB
ioB•10mo ago
you cannot get an accurate benchmark off of one deletion, so no, but you can do what @BuenoFan suggested
NDH
NDH•10mo ago
const start = performance.now();
// do something
const took = performance.now() - start;
const start = performance.now();
// do something
const took = performance.now() - start;
babakfp
babakfp•10mo ago
Alright, thanks guys 🌸🌸