Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
81–90 of 234 posts
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#82How about extending this to comparing programming language efficiency from a developer's standpoint, looking at bytes of code, versus the execution time? I took the source code file size from the repository, and the runtime from the blog post. Then I made an arbitrary overall "PAIN SCORE" (lower is better) by multiplying code size * runtime. I suggest this is a worthwhile metric simply because lower is better on both…
We'd need a stdlib that works across languages for the approach to be successful. nimpylib and similar libraries in other languages are a step in that direction.
Alternatively, the python stdlib itself could be rewritten in python and transpiled to other languages. Perhaps it'd help alternative python implementations in terms of compatibility.
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#83For those curious about Rust optimization, the “optimized” version makes three changes compared to the “idiomatic” version: * It uses byte strings instead of UTF-8 strings. In my opinion, that’s not an optimization, that’s changing the problem. Depending on the question you’re asking, only one of the two can be correct. * It uses a faster hash algorithm. It’s not the first time this came up in a benchmark article. Ru…
Ad uft8: it would change the problem only if the definition of word breaks changed. E.g., if a word break is defined by whitespace, then it probably doesn't.
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#84Earlier quoted context omitted.
Ad uft8: it would change the problem only if the definition of word breaks changed. E.g., if a word break is defined by whitespace, then it probably doesn't.
What happens when the ASCII character for space is embedded within a multibyte UTF-8 codepoint?
So if your solution gets word splitting (or lowercasing) wrong for non-ASCII input, it still gets a pass according to my reading.
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#85Your Perl implementation is almost as fast as c++? Something weird is going on here. Maybe you are bottlenecked on disk read speeds or something.
This is the kind of thing where perl really shines.
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#86Earlier quoted context omitted.
Ad uft8: it would change the problem only if the definition of word breaks changed. E.g., if a word break is defined by whitespace, then it probably doesn't.
What happens when the ASCII character for space is embedded within a multibyte UTF-8 codepoint?
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#87Earlier quoted context omitted.
Ad uft8: it would change the problem only if the definition of word breaks changed. E.g., if a word break is defined by whitespace, then it probably doesn't.
What happens when the ASCII character for space is embedded within a multibyte UTF-8 codepoint?
Now if you want to also split on U+200B (ZERO WIDTH SPACE), U+202F (NARROW NO-BREAK SPACE), etc... hoo boy.
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#88This is a rather meaningless comparison, since the differences are going to be dominated by: 1) The choice of libraries/datatypes used for strings and word->count map 2) How the source file is split into words - probably library function again, although in C/C++ one could choose to implement a super-optimized low level version that would blow the others away IMO a performance comparison between languages is only mean…
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#89Wow. Swift, touted as "safe by design and (...) runs lightning-fast"[1] is more of a screw-up than I thought. Almost twice as slow as Lua and behind even Pascal and Forth. [1] https://developer.apple.com/swift/
Swift is in the same or better performance bracket then C#/Java and unsafe usage can be close to performance of C (maybe 1.3-2x slower). I'm not sure about ranting for poor single test results :P
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#90This is a rather meaningless comparison, since the differences are going to be dominated by: 1) The choice of libraries/datatypes used for strings and word->count map 2) How the source file is split into words - probably library function again, although in C/C++ one could choose to implement a super-optimized low level version that would blow the others away IMO a performance comparison between languages is only mean…