听说VBS比JS快好多,然而还不会VBS
像这种好几百兆的文本处理,VBS是不是快好多呢。路过的来一个VBS。
测试数据——————生成数据307M- @if(0)==(0) echo off& cscript -nologo -e:jscript "%~f0"&pause&exit /b&@end
-
- var s1 = "TCACDFE-----T7G0345444_ABCE1403240013200.txt 14365184 3243 3243 DFSFE 720 5 13 12 9 47 152 297 54 64 32 32\r\n";
- s1 += "TCACTTT-----AEG0342344_LOKIJ1403343313200.txt CE363134 3243 3243 CCFEF 720 5 13 13 9 47 145 297 50 64 32 33\r\n";
- s1 += "TCACAJUE-----T7G0343954_ABCE1403240013200.txt 14036H 3243 3243 FDSFDF 720 5 23 12 9 47 144 297 52 64 32 32\r\n";
- s1 += "CCE T2210 SSECS-----T7G0345334_ABCE1403240013200.txt 14069188010 3243 3243 CCFEF 720 5 13 12 9 47 143 297 10 64 32 32\r\n";
-
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- f = fso.CreateTextFile("1.txt");
- for(var i=0;i<700000;i++){
- f.WriteLine(s1);
- }
- f.Close();
复制代码 JS处理的话--6核CPU、6G内存,80秒- @if(0)==(0) echo off& cscript -nologo -e:jscript "%~f0"&pause&exit /b&@end
-
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var f = fso.OpenTextFile("1.txt",1);
- rf = fso.CreateTextFile("2.txt", true);
- var r = /^(.*\.txt\s+)(\w+)(.*)$/;
- r.compile(r);
- while(!f.atEndOfStream){
- var line=f.ReadLine();
- line.replace(r, function($0,$1,$2,$3){
- rf.WriteLine($2+"@"+$1+"("+$2+")"+$3);
- });
- }
- f.close();
- rf.close();
复制代码
|