News for hackers. Stuff that matters.
Re:Performance comparison: counting words in Python, Go, C++... by w-m on Monday March 15, 2021 @12:50PM (#26468361)
Similar here, reading the file from stdin on a 2020 MBP on macOS 11.2.2 is incredibly slow.

    int main() {
        std::ios::sync_with_stdio(false);
        std::string str((std::istreambuf_iterator<char>(std::cin)),
                         std::istreambuf_iterator<char>());
    }
takes around 8 seconds to run, no counting at all.

    int main() {
        std::ifstream f("kjvbible_x10.txt");
        std::string str((std::istreambuf_iterator<char>(f)),
                         std::istreambuf_iterator<char>());
    }
runs in ~270 miliseconds. Factor 30x, yikes.

There are no comments on this comment yet.