raz / test / nanos.sh

9 lines · 283 B · raw · history · last change 84f97627

1#!/bin/sh
2# The time in nanoseconds, for the timing scripts: date +%s%N is GNU's;
3# BSD's date prints a literal N there, and perl, which macOS has, then
4# gives the time.
5n=$(date +%s%N)
6case $n in
7*N) perl -MTime::HiRes=time -e 'printf "%.0f\n", time * 1e9' ;;
8*) echo "$n" ;;
9esac