4 ms·
For more language benchmarks of this sort, there is a pretty extensive list: https://benchmarksgame-team.pages.debian.net/benchmarksgame/index.html https://ben
by throwaway13337 6y ago
For more language benchmarks of this sort, there is a pretty extensive list:
https://benchmarksgame-team.pages.debian.net/benchmarksgame/index.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
Here, they have code samples and multiple implementations of each task in each language.
It's a great resource for, at a glance, how performant a language is at basic cpu and memory intensive tasks and how simple the related code is.
It still has the issue that some code is unrealistically optimized for the language. And also that many solutions use standard libraries written in other languages. It's worth looking at the source, therefore.
- _ph_ 6y agoI am very sceptical of these benchmarks for the reasons you listed. The individual implementations are often too different to give a comparable score. And sometimes this is because of the rules. Like the requirement to use the language-provided hash tables, while C is free to implement an optimized hash table for the problem.
- igouy 6y agoYou are very sceptical of which benchnmarks ? For the benchmarks game, C is not free to implement an optimized hash table for the problem. The hash table used is from "Klib: a Generic Library in C". https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/knucleotide-gcc-1.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- _ph_ 6y agoJust looking at the first lines of the linked code, I see the following: // Define a custom hash function to use instead of khash's default hash // function. This custom hash function uses a simpler bit shift and XOR which // results in several percent faster performance compared to when khash's // default hash function is used. quite contradicting your statement.
- igouy 6y agoAgain, for the benchmarks game, C is not free to implement an optimized hash table for the problem. Any of the programs are free to implement a "custom hash function" and many of them do. hash table != hash function
- _ph_ 6y agoThat is picking terms. Many languages don't allow to specify custom hash functions, so you can't specify the hash functions until you do write a custom hash table. A fair benchmark would allow for this, if it is allowed in C.
- igouy 6y agoThe OP "Performance comparison: counting words in Python, Go, C++, C, Awk, Forth, Rust" does not allow external libraries BUT then makes an exception for C, and then makes a further exception -- In the optimized version we’ll roll our own hash table. Wikipedia is your friend -- "A hash table uses a hash function to compute an index, also called a hash code …" Which languages shown on the benchmarks game website 'don't allow to specify custom hash functions …" ? https://en.wikipedia.org/wiki/Hash_function https://en.wikipedia.org/wiki/Hash_function
- _ph_ 6y agoI was not talking about the article but the benchmark site linked. Not sure what you want to say with the wikipedia citation. I have not made a comprehensive list, but the topic has come up when discussing one of the Go benchmarks. The Go language has a build-in hashtable, called a map, and this does not allow to specify custom hash functions. Of course rolling out a hashtable implementation which does allow this is prohibited by the benchmark rules. Probably intentionally, also like your distraction attempts are hinting to.
- igouy 6y agoSo you say "Many languages don't allow to specify custom hash functions" but can only name one? > Probably intentionally Wow.
- igouy 6y agoPlease share the widely agreed criteria to identify code we would all call "unrealistically optimized" ;-) 2 tasks — pidigits & regex-redux — explicitly allow use of standard libraries (GMP, PCRE2, RE2) written in other languages. 8 tasks do not. (Those standard libraries were allowed because some language implementations provided arbitrary precision arithmetic or regex by wrapping those standard libraries.) Of course, realistic use of some languages relies on calling standard libraries written in other languages.