var openReadCount = 1;
var totalOpenReadCount = 200;
var openReadTotalTime = 0;
var fsopenread = function (size, url) {
var ot = Date.now();
fs.open({
filePath: url,
success(res) {
console.log("resfd:",res)
let fd = res.fd;
var ab = new ArrayBuffer(size);
fs.read({
fd: fd,
arrayBuffer: ab,
length: 0,
success(res) {
var useTime = Date.now() - ot;
openReadTotalTime += useTime;
if (openReadCount == totalOpenReadCount) {
console.log("fs open read 耗时:", openReadCount + '次数', "总耗时/平均耗时:" + openReadTotalTime + "ms/" + openReadTotalTime / openReadCount + "ms");
}
if (openReadCount == 1) {
console.log("fs open read 耗时:", openReadCount + '次数', "总耗时/平均耗时:" + openReadTotalTime + "ms/" + openReadTotalTime / openReadCount + "ms");
}
if (openReadCount == 20) {
console.log("fs open read 耗时:", openReadCount + '次数', "总耗时/平均耗时:" + openReadTotalTime + "ms/" + openReadTotalTime / openReadCount + "ms");
}
if (openReadCount == 100) {
console.log("fs open read 耗时:", openReadCount + '次数', "总耗时/平均耗时:" + openReadTotalTime + "ms/" + openReadTotalTime / openReadCount + "ms");
}
ab = null;
fs.close({
fd:fd,
success(res){
openReadCount++;
if (openReadCount <= totalOpenReadCount) {
fsopenread(size, url);
}
},
fail(res){
console.log("close error:",res)
}
})
},
fail(res) {
console.log("fs read error:", res)
}
})
},
fail: (res) => {
console.log("open error:", res, "openCount:", openReadCount)
}
})
}
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。