2

Hopefully not a dupe of this question...

I'm trying to determine the curve of a specified program's runtime with the time function.

What I would like to do is automate this process to get several hundred points of data to graph in Excel, however I am getting different output when running in a Linux terminal vs a bash script.

Here is what I get when I run it from the terminal:

time program_1 500
> 0.004u 0.000s 0:00.00 0.0%   0+0k 0+0io 0pf+0w

and here is my bash script (first argument is the program, second is the number)

#!/bin/bash

time $1 $2

and here...my output is different, even though when I echo the above statement in a literal manner, it appears to be the exact same call.

> sh runner.sh program_1 500
> 0.00user 0.00system 0:00.00elapsed 400%CPU (0avgtext+0avgdata 3488maxresident)k0inputs+0outputs (0major+275minor)pagefaults 0swaps

Why the difference?

1 Answer 1

3

Well, there are actually 2 time commands, and one of them is built into bash. man bash for the one installed in /usr/bin/time and help time for the builtin. Use the absolute path in your script to get same behaviour.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.