Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Benchmark a linux Bash script

Is there a way to benchmark a bash script's performance? the script downloads a remote file, and then makes calls to multiple commandline programs to manipulate. I would like to know (or as much as possible):

  • Total time
    • Time spent downloading
    • Time spent on each command called
    • -=[ I think these could be wrapped in "time" calls right? ]=-
  • Average download speed
    • uses wget
  • Total Memory used
  • Total CPU usage
    • CPU usage per command called

I'm able to make edits to the bash script to insert any benchmark commands needed at specific points (ie, between app calls). Not sure if some "top" ninja-ry could solve this or not. Not able to find anything useful (at least to limited understanding) in man file.

Will be running the benchmarks on OSX Terminal as well as Ubuntu (if either matter).

like image 680
mondo Avatar asked Nov 06 '11 22:11

mondo


1 Answers

strace -o trace -c -Ttt ./scrip
  1. -c is to trace the time spent by cpu on specific call.
  2. -Ttt will tell you time in microseconds at time of each system call running.
  3. -o will save output in file "trace".
like image 62
Farhan Avatar answered Oct 14 '22 08:10

Farhan