Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Add timestamps to Unix commands that run at intervals' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Add timestamps to Unix commands that run at intervals
Authored by: slvrstn on Jan 24, '10 09:07:11PM

In the end, both perl and the `date` command are making the same system library call, time.
See `man -s 3 time`

The difference is all in the overhead in setting up the execution environment.
In the perl, this is done once and the interpreter can then make rapid-fire system calls.
In the bash (and awk) examples, every invocation of `date` has to exec a full new command / execution environment, which is comparatively extremely resource intensive.

bash is a fantastic and very capable shell, but unless your script is written entirely with built-ins, you are going to pay a performance penalty for every external command invoked. This isn't something exclusive to bash, of course. You have the same issues in Perl, in fact, if your script relies heavily on using the system, exec, or backtick commands.

[ Reply to This | # ]