Closed josephmturner closed 1 month ago
Is this a sufficient benchmark?
test.only('benchmark', async (t) => {
const created = await nextURL(t)
const uploadLocation = new URL('./example.txt', created)
await fetch(uploadLocation, { method: 'put', body: SAMPLE_CONTENT })
console.time('drive size test')
for(var i=0; i < 1000; i++){
await fetch(uploadLocation, { method: 'head' })
}
console.timeEnd('drive size test')
})
I added that to test.js
and ran it on the x-drive-size
feature branch:
> hypercore-fetch@9.7.0 test
> node test
TAP version 13
# benchmark
ok 1 Created new drive
hi
with drive size: 824.243ms
1..1
# tests 1
# pass 1
# ok
And on master branch:
> hypercore-fetch@9.7.0 test
> node test
TAP version 13
# benchmark
ok 1 Created new drive
hi
without drive size: 796.518ms
1..1
# tests 1
# pass 1
# ok
Results:
(824.243 - 796.518) / 796.518 = 0.0348
This benchmark indicates a 3.5% performance hit, but it might be more with many files on disk (instead of just one file in memory).
I can add request header flag like X-With-Drive-Size
if you think that makes sense.
This code is based on the
drives info
CLI command.