News for hackers. Stuff that matters.
Re:Yes, PHP is faster than C# by cakoose on Wednesday March 16, 2022 @09:18PM (#30706369)
This code has a bug that can cause the count to be overreported. The last `file.Read` may only partially fill the buffer, but this code will look for 1s in the entire buffer.

(This bug won't affect the performance comparison, but I was just reminded of how error prone these kinds APIs can be vs the PHP/Python route of having the library function just allocate a new buffer each time.)

Re:Yes, PHP is faster than C# by kerblang on Thursday March 17, 2022 @10:31AM (#30711593)
Would something like this help? (No of course I haven't compiled it.)

    int len;
    while ((len=file.Read(buf,0,buf.Length)) > 0) {
        for (int i=0; i<len; i++_) {
            if (buf[i] == '1') {
                counter++;
            }
        }
    }