bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] nanoseconds


From: pourko
Subject: [PATCH] nanoseconds
Date: Tue, 23 Sep 2025 12:18:45 +0200 (CEST)

This implements the special variable NANOSECONDS in Bash.

Rationale:

Bash on Cygwin has some terrible clock resolution for EPOCHREALTIME: 
Numerous consecutive references to EPOCHREALTIME can all yield the same
number, thus rendering EPOCHREALTIME unusable for precise time-measurement.

Luckily, it turns out that CLOCK_MONOTONIC has a perfect nanosecond-
resolution there. With this new NANOSECONDS var, a script can have the 
option to chose which clock will suite it best on different platforms. 

As an added bonus, I have always wanted to have a raw clock reading, 
so I don't have to worry about the overhead of removing decimal points
when doing math on some readings.

Patch (apply with `patch -p0'):


Attachment: bash-5.3-nanoseconds.patch.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]