Ad Widget

Collapse

Measure execution time of a script/command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SBO
    Zabbix Certified Specialist
    Zabbix Certified Specialist
    • Sep 2015
    • 226

    #1

    Measure execution time of a script/command

    Hi,

    Quick question for you guys.
    I currently have a script that makes an API call to one of our platform, and returns a result.
    I'd like to monitor the execution time of the script.

    I thought about encapsulating this script in a bash script, something like
    Code:
    #!/bin/bash
    START=$(date +%s.%N)
    /path/to/my/script
    END=$(date +%s.%N)
    DIFF=$(echo "$END - $START" | bc)
    echo $DIFF
    But I'm pretty sure there's a prettier way to do so.
    Any clue ?
    Ideally, the result should be in ms.
  • Colttt
    Senior Member
    Zabbix Certified Specialist
    • Mar 2009
    • 878

    #2
    hmm you can use time something like:

    Code:
    /usr/bin/time  -f "%e" <Script>
    4.22
    Debian-User

    Sorry for my bad english

    Comment

    Working...