|
|
|
|
|
|
Process 2100 files with boost::split (without read in whole file) 832 sec Process 2100 files with custom split (without read in whole file) 311 sec Process 2100 files with custom split (read in whole file) 342 sec |
|
|
|
|
|
|
Process 2100 files with boost::split (without read in whole file) 832 sec Process 2100 files with custom split (without read in whole file) 311 sec Process 2100 files with custom split (read in whole file) 342 sec |
each file contain lines like this: |
a1,1,1,3.5,5,1,1,1,0,0,6,0,155,21,142,22,49,1,9,1,0,0,0,0,0,0,0 a1,10,2,5,5,1,1,2,0,0,12,0,50,18,106,33,100,29,45,9,8,0,1,1,0,0,0 a1,19,3,5,5,1,1,3,0,0,18,0,12,12,52,40,82,49,63,41,23,16,8,2,0,0,0 a1,28,4,5.5,5,1,1,4,0,0,24,0,2,3,17,16,53,53,63,62,43,44,18,22,4,0,4 a1,37,5,3,5,1,1,5,0,0,6,0,157,22,129,18,57,11,6,0,0,0,0,0,0,0,0 a1,46,6,4.5,5,1,1,6,0,0,12,0,41,19,121,31,90,34,37,15,6,4,0,2,0,0,0 a1,55,7,5.5,5,1,1,7,0,0,18,0,10,9,52,36,86,43,67,38,31,15,5,7,1,0,1 a1,64,8,5.5,5,1,1,8,0,0,24,0,0,3,18,23,44,55,72,57,55,43,8,19,1,2,3 a1,73,9,3.5,5,1,1,9,1,0,6,0,149,17,145,21,51,8,8,1,0,0,0,0,0,0,0 a1,82,10,4.5,5,1,1,10,1,0,12,0,47,17,115,35,96,36,32,10,8,3,1,0,0,0,0 |
|
|
I have 6 types need to handle. But all are similar. |
I tried read line by line (not whole file into memory) before, and it takes 312 sec to process 2100 files. |
That's probably because you're handling the data too much. You should only read the file once. You should only |
no, my first try is open the file, read 1 line into stringstream (using getline) and parse the line (use the split function and extract 4 items in it). But this still take 312 sec and so I consider read the whole file into memory (into string/vector<char>/char *) hope to improve performance. |
|
|