Performance comparison: counting words in Python, Go, C++, C, AWK, Forth, and Rust

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/programming

Our great sponsors
  • Scout APM - Less time debugging, more time building
  • SonarQube - Static code analysis for 29 languages.
  • SaaSHub - Software Alternatives and Reviews
  • countwords

    Playing with counting word frequencies (and performance) in various languages.

    Thanks -- good call. I definitely wasn't too focused on testing/hardening for this article. Someone submitted a PR to fix the no-NUL issue: https://github.com/benhoyt/countwords/pull/29

  • abseil-cpp

    Abseil Common Libraries (C++)

    For those looking for a performant hash map in C++, absl::flat_hash_map is a good choice. It's very nearly a drop in replacement for std::unordered_map. I know there are some other goods one out there as well, this is just the one I use at work.

  • Scout APM

    Less time debugging, more time building. Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development.

  • parallel-hashmap

    A family of header-only, very fast and memory-friendly hashmap and btree containers.

    The use of unordered_map and the unnecessary copy stood out to me also. I changed the copy to a move, and replaced std::unordered_map with phmap::flat_hash_map(a drop in, header-only replacement, link). I got 1.56s for the original version, and 1.29s for the new version. Scaling the results so my 1.56s corresponds to his 1.75s, the new version would land at ~1.45s on his computer, about on par with the Rust results.

  • wordcount

    Counting words in different programming languages.

    Another similar experiment. And has Java included :)

  • llfio

    P1031 low level file i/o and filesystem library for the C++ standard

    I'm using stdio instead of iostream, because why not. Further improvements possible with llfio.

  • Klib

    A standalone and lightweight C library

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts