Last active
September 13, 2025 22:34
-
-
Save lordjabez/4bfcf3b7c69cea57d249ba55e16f9b09 to your computer and use it in GitHub Desktop.
Time a command in bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
command=$1 | |
start_time=$(date +%s.%N) | |
$command | |
end_time=$(date +%s.%N) | |
duration=$(echo "$end_time - $start_time" | bc) | |
echo "Execution took ${duration} seconds" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment