3 ms·
A couple of years ago, I made the same exercise and, when benchmarking several real-world languages, I got similar results. On a slowish Intel CPU (from my memo
by nwellnhof 9y ago
A couple of years ago, I made the same exercise and, when benchmarking several real-world languages, I got similar results. On a slowish Intel CPU (from my memory):
DFA-based decoder: ~400 MB/s
Naive decoder with ASCII: ~1.2 GB/s
Naive decoder with with most Western languages: ~1.0 GB/s
Naive decoder with with Russian, Chinese, Japanese: ~800 MB/s
Branch prediction of modern CPUs is so good that it's hard to beat the naive if-else chain with real-world data. Interestingly, I got the worst performance with heavily accented Eastern European languages like Czech where performance dropped to 600-700 MB/s.
- bzbarsky 9y ago> Branch prediction of modern CPUs is so good Modern x86 CPUs. ARM branch prediction is much worse, unfortunately.