|
1 | 1 | #!/usr/bin/env node |
2 | | -var path=process.argv[2]; |
3 | | -var fs=require('fs'); |
4 | | -if (!fs.existsSync(path)){ |
| 2 | +var path = process.argv[2]; |
| 3 | +var fs = require('fs'); |
| 4 | +if (!fs.existsSync(path)) { |
5 | 5 | console.log("Run: benchmark [csvpath]"); |
6 | | - console.log("File not found: ",path); |
| 6 | + console.log("File not found: ", path); |
7 | 7 | process.exit(1); |
8 | 8 | } |
9 | | -function testCSVLine(coreNum,checkType,cb){ |
10 | | - console.log("WorkerNum:",coreNum,"Check Type: ",checkType); |
11 | | - var Converter=require("../libs/core/Converter"); |
12 | | - var rs=fs.createReadStream(path); |
13 | | - var converter=new Converter({ |
14 | | - workerNum:coreNum, |
15 | | - checkType:checkType, |
16 | | - constructResult:false |
| 9 | +function testCSVLine(coreNum, checkType, cb){ |
| 10 | + console.log("WorkerNum:", coreNum, "Check Type: ", checkType); |
| 11 | + var Converter = require("../libs/core/Converter"); |
| 12 | + var rs = fs.createReadStream(path); |
| 13 | + var converter = new Converter({ |
| 14 | + workerNum: coreNum, |
| 15 | + checkType: checkType, |
| 16 | + constructResult: false |
17 | 17 | // fork:true |
18 | 18 | }); |
19 | | - var totalLines=0; |
20 | | - var secLines=0; |
21 | | - converter.on("data",function(){ |
22 | | - totalLines++; |
23 | | - secLines++; |
| 19 | + var totalLines = 0; |
| 20 | + var secLines = 0; |
| 21 | + converter.on("data", function() { |
| 22 | + totalLines++; |
| 23 | + secLines++; |
24 | 24 | }); |
25 | | - converter.on("end",function(){ |
| 25 | + converter.on("end", function() { |
26 | 26 | clearInterval(timer); |
27 | 27 | console.log(""); |
28 | | - var t=new Date()-start; |
29 | | - console.log("Time elapsed: ",t, " ms"); |
30 | | - console.log("Total lines: "+totalLines); |
31 | | - console.log("Average Speed: "+Math.round(totalLines/t*1000)+" Lines / Sec"); |
| 28 | + var t = new Date() - start; |
| 29 | + console.log("Time elapsed: ", t, " ms"); |
| 30 | + console.log("Total lines: " + totalLines); |
| 31 | + console.log("Average Speed: " + Math.round(totalLines / t * 1000) + " Lines / Sec"); |
32 | 32 | cb(); |
33 | | - }) |
34 | | - var timer=setInterval(function(){ |
35 | | - process.stdout.write("\r"+secLines+" CSV Lines/Sec"); |
36 | | - secLines=0; |
37 | | - },1000); |
38 | | - var start=new Date(); |
| 33 | + }); |
| 34 | + var timer = setInterval(function() { |
| 35 | + process.stdout.write("\r" + secLines + " CSV Lines/Sec"); |
| 36 | + secLines = 0; |
| 37 | + }, 1000); |
| 38 | + var start = new Date(); |
39 | 39 |
|
40 | | - var stream=rs.pipe(converter); |
| 40 | + var stream = rs.pipe(converter); |
41 | 41 | } |
42 | 42 |
|
43 | 43 | // testCSVLine(1,false,false,function(){ |
|
0 commit comments