5

When I test a perl script under linux and use time sh -c to measure the time spent, I got a weird result:

real    14m11.903s
user    34m39.319s
sys     16m54.074s

which means the real time spent is even less than user time. And visually counting the time by myself, the script didn't spent as much as 34 minutes, and real time is closer to what I see. Has anyone have any clue about this? Thanks.

lolibility
  • 2,187
  • 6
  • 25
  • 45

2 Answers2

12

The script could have used more than 1 core.

timos
  • 2,637
  • 18
  • 21
  • Yes that't true, so if I have a multi-thread script with 4 threads working and user time is 16m, can I say the real time is about 4m? – lolibility Oct 11 '12 at 14:35
  • It depends on a lot of things. Typically due to shared resource constraints (memory, disk, mutex sections, etc) it won't work out that perfectly. – jmh Oct 11 '12 at 14:39
1

The user line is showing the total CPU time that the process used directly. If your process has more than one thread and your cpu has more than one core then you may use more CPU time than wall clock time.

jmh
  • 8,856
  • 1
  • 18
  • 26