AlexLordThorsen
AlexLordThorsen

Reputation: 8488

Time produces weird results with leading sudo call

If I run time without sudo

$ time python test_file_cmp.py

real    31m5.439s
user    1m31.057s
sys 4m51.030s

With sudo

$ sudo time python test_file_cmp.py 
[sudo] password for user: 
92.13user 299.38system 30:41.26elapsed 21%CPU (0avgtext+0avgdata 6172maxresident)k
237041856inputs+221771216outputs (0major+54789minor)pagefaults 0swaps

Why is this?

Upvotes: 1

Views: 83

Answers (1)

John Kugelman
John Kugelman

Reputation: 361615

time is a shell builtin. When you write sudo time ... that invokes the executable time on your $PATH (/usr/bin/time, perhaps) rather than the builtin.

Try time sudo ... or sudo sh -c 'time python ...' instead.

Upvotes: 2

Related Questions