3 ms·
Ask HN: Really long shell command more performant than many short ones?
I'm experiencing something that I'm not sure about.
I'm noticing a huge performance gain between concatenating commands with && and running the commands one by one.
None of the commands fail, so I'm not sure why that would be.
Is this normal?
- anonymous_iam 10y agoCould you please provide an example?
- nkkollaw 10y agoI'm on mobile :-/ I'll post again once I'm back at the PC.
- savethefuture 10y agoCould it be network lag from a remote server? And when doing single commands the prompt doesn't appear right away, so it seems slower?
- CyberFonic 10y agoWhen using remote servers, especially when connecting via HSDPA, I prefer to use https://mosh.org https://mosh.org instead of ssh. Although it doesn't impact upon the underlying processing speed, the console terminal becomes more responsive.
- CyberFonic 10y agoWhich shell, which OS? Is it within a script or when entering from the console? Have you actually timed your tests? My first reaction to your question was that each command is executed as a separate process and depending on what you are doing, e.g. piping outputs to inputs, using temporary files, other operations could create lots of variances between one run and the next.
- tedmiston 10y agoPerhaps the CPU scheduler is working to your disadvantage with multiple commands running separately. Another thought is maybe data is in a faster state of cache in the combined command, but in separate commands is getting dumped to something slower.