31 lines
794 B
Plaintext
31 lines
794 B
Plaintext
var fd = use('fd')
|
|
var time = use('time')
|
|
var blob = use('blob')
|
|
|
|
return {
|
|
test_chunkread: function() {
|
|
// Create temp file
|
|
var tmp = "chunk_test.tmp"
|
|
var f = fd.open(tmp, 'w')
|
|
var bigdata = ""
|
|
for(var i=0; i<100; i++) bigdata += "HelloWorld" // 1000 bytes
|
|
fd.write(f, bigdata)
|
|
fd.close(f)
|
|
|
|
var data = blob()
|
|
var st = time.number()
|
|
var f2 = fd.open(tmp, 'r')
|
|
var chunksize = 1024 // reduced for test
|
|
|
|
while(true) {
|
|
var chunk = fd.read(f2, chunksize);
|
|
data.write_blob(chunk);
|
|
if (length(chunk) < chunksize * 8) break;
|
|
}
|
|
fd.close(f2)
|
|
log.console(`read took ${time.number()-st}`)
|
|
|
|
fd.unlink(tmp)
|
|
}
|
|
}
|