¿Cómo contar líneas rápidamente?

Lo intenté unxutils' wc -l pero se bloqueó por archivos de 1GB. Probé este código C #

long count = 0;
using (StreamReader r = new StreamReader(f))
{
    string line;
    while ((line = r.ReadLine()) != null)
    {
        count++;
    }
}

return count;

Lee un archivo de 500 MB en 4 segundos

var size = 256;
var bytes = new byte[size];
var count = 0;
byte query = Convert.ToByte('\n');
using (var stream = File.OpenRead(file))
{
    int many;
    do
    {
        many = stream.Read(bytes, 0, size);
        count += bytes.Where(a => a == query).Count();                    
    } while (many == size);
}

Lee en 10 segundos

var count = 0;
int query = (int)Convert.ToByte('\n');
using (var stream = File.OpenRead(file))
{
    int current;
    do
    {
        current = stream.ReadByte();
        if (current == query)
        {
            count++;
            continue;
        }
    } while (current!= -1);
}

Toma 7 segundos

¿Hay algo más rápido que aún no haya probado?

Respuestas a la pregunta(6)

Su respuesta a la pregunta