Skip to content

Instantly share code, notes, and snippets.

@eevmanu
Last active June 15, 2023 23:11
Show Gist options
  • Save eevmanu/76899a770bf57cb7861c36db5517f765 to your computer and use it in GitHub Desktop.
Save eevmanu/76899a770bf57cb7861c36db5517f765 to your computer and use it in GitHub Desktop.
bash benchamrking in nanoseconds
start=$(date +%s%N)
# any command
end=$(date +%s%N)
elapsed_nanosec=$((end - start))
formatted_elapsed_nanosec=$(printf "%'d" "$elapsed_nanosec" | sed 's/,/_/g')
echo "Elapsed time: $formatted_elapsed_nanosec nanoseconds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment