5 ms·
>If we just run /bin/true, we can do 500 of them in a second, so it looks like running any program has about 1ms of overhead. This is off by at least three ord
by asifgdinio 6y ago
>If we just run /bin/true, we can do 500 of them in a second, so it looks like running any program has about 1ms of overhead.
This is off by at least three orders of magnitude, at least on my machine.
$ time for i in $(seq 1000000); do true; done
real 0m1.049s
user 0m1.037s
sys 0m0.019s
This article would be better if it were about computers in general, not about Python. I specifically avoid using Python for anything serious because I find its performance impossible to reason about. Then again, perhaps it's a good thing to have examples that require thinking rather than just reciting the machine's specs like most of these lists I've seen.
- mrob 6y agoYour "true" is probably a shell builtin. Try it with /bin/true instead.
- FastedCoyote 6y agoTwo tips, if you're using Bash: 1. Use the external "true" command. 2. Use {a..b} to expand sequences of numbers as "seq" adds extra overhead. $ time for i in {1..500}; do /bin/true; done real 0m0.983s user 0m0.650s sys 0m0.423s