var fd = use('fd')
var time = use('time')
var blob = use('blob')

return {
    test_chunkread: function() {
        var tmp = "chunk_test.tmp"
        var f = fd.open(tmp, 'w')
        var bigdata = ""
        var i = 0
        var chunk = null
        for (i = 0; i < 100; i++) bigdata += "HelloWorld"
        fd.write(f, bigdata)
        fd.close(f)

        var data = blob()
        var st = time.number()
        var f2 = fd.open(tmp, 'r')
        var chunksize = 1024

        while (true) {
            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)
    }
}
