From 20f956fd825dcd90a0223261134387ae2e1d9a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A6=E5=AA=9B=E5=A7=A3?= <3400986906@qq.com> Date: Mon, 20 Feb 2023 21:00:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test.js" | 34 +++++++++++++++++++ .../work.js" | 26 ++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 "\351\237\246\345\252\233\345\247\243/\346\226\207\344\273\266\344\275\234\344\270\2322/test.js" create mode 100644 "\351\237\246\345\252\233\345\247\243/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/work.js" diff --git "a/\351\237\246\345\252\233\345\247\243/\346\226\207\344\273\266\344\275\234\344\270\2322/test.js" "b/\351\237\246\345\252\233\345\247\243/\346\226\207\344\273\266\344\275\234\344\270\2322/test.js" new file mode 100644 index 00000000..9c64d40c --- /dev/null +++ "b/\351\237\246\345\252\233\345\247\243/\346\226\207\344\273\266\344\275\234\344\270\2322/test.js" @@ -0,0 +1,34 @@ +//创建模块 +let fs = require("fs"); + +console.log(fs); + +let arr=[]; +let max=0; +let min=1001; + +let maxFile=0; + +let minFile=0; + +for(var i=1;i<=100;i++){ + var num=Math.ceil(Math.random()*1000);//创建随机数 + fs.writeFileSync("./"+i+".txt",""+num+"");//写入文件 + arr[i]=fs.readFileSync("./"+i+".txt".toString());//读取文件 + + //获取最大值 + if(Number(arr[i])>max){ + max=Number(arr[i]); + maxFile=i; + } + + //获取最小值 + if(Number(arr[i]){ + num++; + if(num==1000){ + let t2=new Date().getTime(); + let tc=t2-t1; + console.log("异步耗时为:" + tc + "ms") + } + }) +} -- Gitee