简体   繁体   中英

/usr/bin/time and time in multicore platform

guys. I am confused about the result below:

1). time xxxxx

 real 0m28.942s
 user 0m28.702s
 sys 0m0.328s

2). /usr/bin/time -p xxxxx

real 28.48
user 0.00
sys 0.13

so. I have some question(user: 0m28.702s != 0, sys: 0m0.328s != 0.13):

  1. what's different between time and /usr/bin/time ?
  2. what's different in differnt cpu platform, one core or multicore ?

any suggestion?

It's quite easy to find out the answer to your first question using type :

$ type time
time is a shell keyword
$ type /usr/bin/time
/usr/bin/time is /usr/bin/time

So the first command uses a bash built-in, while the latter defers to an external program. However, not knowing what system you are using, I have no idea where that program comes from. On Gentoo Linux, there's no /usr/bin/time by default, and the only implementation available is GNU time that has different output.


That said, I have tried a command similar to yours (assuming it's working on a 1G file), and got the following results:

$ time sed -e 's/0//g' big-file > big-file2

real    0m40.600s
user    0m31.295s
sys     0m4.174s

$ /usr/bin/time sed -e 's/0//g' big-file > big-file2
35.06user 3.31system 0:40.58elapsed 94%CPU (0avgtext+0avgdata 3488maxresident)k
8inputs+2179176outputs (0major+276minor)pagefaults 0swaps

As you can see, the numbers are similar.

Then, given your results ( 0 userspace time is quite impossible) I'd say that your /usr/bin/time is simply broken. This might be worth reporting a bug to its author.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM