tis - Timestamp command output
Introduction
tis
helps you measure running time of an application. tis
prepends timestamp in μs (the time spent before printing the line)
to each line in stdout of another command.
Please note that there can always be a noise of several 100μs even when run on a free fast machine.
If we try to use bash built-in to measure time, we get similar noise:
echo $EPOCHREALTIME; read -t 0.01; \ echo $EPOCHREALTIME; echo $EPOCHREALTIME
After we discount the time required for consecutive echo
, there's
still often several 100μs of noise plus the timeout of read
command
shall not be accurate (so we may not be measuring 0.01 seconds with a
precision of 1μs).
tis
doesn't count the CPU time spend by itself. So time spend
printing the line itself shall not be counted. Thus, you shall see
that the time for bash built-in echo
command shall be close to 0.
tis
is similar to the ts
from moreutils
(when run as ts -i "%.s"
).
I wrote tis
because ts
output was unreliable for measuring smaller
time frame - especially during the first few lines.
Source: GitLab
Build and Install
## Install dependencies # Debian and derivatives sudo apt install -y gcc meson # Fedora and derivatives sudo dnf install -y gcc meson ## Build # 'build' used below is a non-existing directory # name. You may use any name of your choice. meson setup build cd build && ninja ## Install sudo ninja install
Running tis
Once you install tis
you can pipe other applications to tis
:
# Measure time spent before printing 'hi' (echo hi; read -t 0.1; echo hi) | tis # Same as above, but show time only if greater than 1ms (echo hi; read -t 0.1; echo hi) | tis -m 1 # Show help tis -h
See also
License
Written in 2024 by Mohammed Sadiq <sadiq@sadiqpk.org>
To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see the license online.