Earlier quoted context omitted.
What is there to benchmark between C++, C, Rust, or any other low level compiled language though? With any one of them you can essentially achieve the same assembly code generation, if you try hard enough. In the end it either boils down to compiler optimisations or library implementations.
I think the interesting question there (and really any language comparison) is to compare the result of idiomatic implementations. Unfortunately, there is no clear answer on what is idiomatic, even with something like Python that is more opinionated than most on the question.
Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
201–210 of 234 posts
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#202Earlier quoted context omitted.
I only skimmed the article, but I suspect they are including the time necessary to spin up the executable and any runtime environment prior to executing the relevant code. "Lightning fast" can mean a lot of things, and it might not mean "executables start quickly."
If that were the case, that makes Java's results fairly impressive, given the JVM's slow start time.
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#203Earlier quoted context omitted.
As I wrote elsewhere in this thread (though I was downvoted), I suspect the reason is that this benchmark is measuring the total execution time of a single run of an executable. This would include any time spent by the executable to bootstrap its runtime environment, initiate a virtual machine, and whatever else it needs to do in addition to the relevant code at hand to process the string. Such a test will favor impl…
I was going to make a general comment about this too. It’s a huge penalty for Java too and has no correlation for how well it performs outside of toy benchmarks
Is that just your assumption or have you measured that penalty for this tiny tiny program?
Might "the JVM's slow start time" in this case be insignificant?
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#204Fun stuff! Did run a similar thing with a simple bioinformatics problem before (calculating the ratio of G and Cs against A+G+C+T), also with a whole bunch of contributors: https://github.com/samuell/gccontent-benchmark#readme Really hard - or impossible - to arrive at a definitive single number for one language, but the whole exercise is a lot of fun and quite informative IMO :)
k-nucleotide
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#205 $ g++ -I robin-hood-hashing/src/include -O2 -flto -std=c++20 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -lfmt
$ time ./a.out /dev/null
0,19s user 0,01s system 99% cpu 0,197 total
with the same build flags, optimize.cpp gives me 0,22s user 0,01s system 99% cpu 0,233 totalRe: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#206Earlier quoted context omitted.
If I were doing the benchmark, I would just run it on a VM with a single physical core. There are good reasons for comparing single threaded performance since it may not be necessary or desirable to scale that way. For example, suppose it's a wc API or something; limiting each request to a single thread can be better since you get fairer scheduling and less data sharing which is almost always better for multiprocessi…
> If I were doing the benchmark, I would just run it on a VM with a single physical core. I think that's definitely an environment worth benchmarking on - but I don't think that it should be the only environment to benchmark on. Also, I don't think it's a good reason to limit implementations to a single thread, even if that is your benchmark environment. It can be worth seeing how well an implementation that's capabl…
Did something like that — programs written for multi-core forced onto one core, alongside programs not written for multi-core.
iirc That difference wasn't something anyone ever expressed interest in.
https://web.archive.org/web/20121231010227/http://benchmarks...
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#207It seems like this is just measuring a single pass at reading a file with about 100k words in it. I ran the benchmark and it finished almost instantly. So languages with startup overhead and warmup time (eg: JIT etc) will totally underperform here. Makes sense then why Java is almost identical between optimised and non-optimised versions.
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
otoh instead of asserting "will totally underperform" please measure and share your measurements!
Sometimes "startup overhead" turns-out to be insignificant.
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#208> We usually think of I/O as expensive, but I/O isn’t the bottleneck here...The tokenization and hash table operations are the bottleneck by a long shot Interesting. This is something I'll have to keep in mind. Best practice is always been to consider I/O the slowest. But, it's true... times have changed. Maybe we shouldn't make this assumption anymore.
He didn't clear the disk cache when profiling so of course the IO overhead was negligible. Had he flushed the cache between runs the numbers would have been very different.
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#209Earlier quoted context omitted.
TFA only talks about gawk, though, making this comparison meaningless ie. you can't benchmark languages but only language implementations . Same goes for other programming languages ofc unless those have only a single implementation. mawk is an order of magnitude faster than gawk, and gawk isn't even the default on many Linuxen.
> TFA only talks about gawk, though, making this comparison meaningless Not exactly! To quote from TFA (I'm the author): > Another “optimization” is to run it using mawk, a faster AWK interpreter than gawk. In this case it’s about 1.7 times as fast as gawk -b. I’m using mawk in the benchmarks for the optimized version.
Re: Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
#210I'm curious why go is faster than rust in the benchmarks. My best theory is that the program doesn't run long enough to trigger a GC, so rust is paying the cost of freeing memory, but go isn't. (Using an arena allocator in rust would probably produce similar behavior). Or maybe the difference is just noise? It's hard to tell without more details on how the benchmarks were run.