result of os.times() is different with 'time' command Options

Tim Roberts timr at probo.com
Sun Mar 14 22:14:56 EDT 2010


hiral <hiralsmaillist at gmail.com> wrote:
>...
>Output:
>real    0.0m0.0100000002421s
>user    0.0m0.0s
>sys     0.0m0.0s
>
>
>Command:
>$ time ls
>
>Output:
>real    0m0.007s
>user    0m0.000s
>sys     0m0.000s
>
>
>Is this the intended behaviour?

What is it that you are wondering about?  The formatting difference is due
to your code.  The difference between 10 milliseconds and 7 milliseconds
could be due to any number of things.  First, you have the overhead of
Python involved in your measurements.  Second, you have the variability of
memory caching and disk caching.  Your Python code causes /bin/ls to be
loaded into memory, and it's probably still in a file cache when you run
the second command.

You can't really do an analysis like this with a task that only takes a few
milliseconds.  There are too many variables.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list