I have a program which I run by command:

time ./my-program.sh

output is:

./my-program.sh 10,31s user 8,13s system 38% cpu 47,308 total

but I don't know, why total time is so long when the system and user time is so short..

Do you anybody know how can I determine why my program takes so long?

Here's the script:


mysql -uroot -ptest --default-character-set=utf8mb4 -e 'select * from
message;' mydatabase > $FILE

cat $FILE |  while read; do ./my-program; done

./my-program is written in C and it transfers the data from my database and saves it.

  • Does it wait for something? If so it might be idle time. – Seth Oct 5 '16 at 10:29
  • Hmm maybe there is waiting than data are load or save on disk.. – Applemann Oct 5 '16 at 10:43
  • Let it run once without the last line and time it. Does it show a similar pattern? If not it's the program (most likely) to debug what's happening there you'd have to do some in depth stuff. Also check this one: What do 'real', 'user' and 'sys' mean in the output of time(1)? – Seth Oct 5 '16 at 10:52
  • 1
    Would this stream flow at about the same rate that text scrolls on the screen? If $FILE is particularly long, I can see that easily taking 30s. – Xalorous Oct 6 '16 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.