How to count lines fast?

前端 未结 6 1392
感情败类
感情败类 2020-12-09 15:34

I tried unxutils\' wc -l but it crashed for 1GB files. I tried this C# code

long count = 0;
using (StreamReader r = new StreamReader(f))
{
    st         


        
6条回答
  •  攒了一身酷
    2020-12-09 15:46

    I think that your answer looks good. The only thing I would add is to play with buffer size. I feel that it may change the performance depending on your buffer size.

    Please refer to buffer size at - Optimum file buffer read size?

提交回复
热议问题