Skip to content

Instantly share code, notes, and snippets.

@lordjabez
Last active September 13, 2025 22:34
Show Gist options
  • Save lordjabez/4bfcf3b7c69cea57d249ba55e16f9b09 to your computer and use it in GitHub Desktop.
Save lordjabez/4bfcf3b7c69cea57d249ba55e16f9b09 to your computer and use it in GitHub Desktop.
Time a command in bash
#!/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