Dear Riccardo and Allin,
Huge thanks to you all! Your enhancements boosted the performance more than threefold! See for yourself: performance comparison of the initial version (AK), Riccardo’s one (RL), Allin’s one (AC) and the final version with the slight improvement (ACRL); measured in results per second (more = better). Tested in 5 runs under Windows and Linux (Debian) on a good modern (AMD FX-6200) and a bad obsolete system (Atom M270).
Perf AK RL AC ACRL
LnxGood 437 1346 2329 2483
WinGood 336 783 967 1026
LnxBad 49 168 347 381
WinBad 43 106 137 146
Might be interesting for you how those extra commands influenced the performance (extra kudos to Linux).