added converter to bsread timestamps

This commit is contained in:
2025-10-16 18:30:11 +02:00
parent 96bd27ffbe
commit 0b8c734782
2 changed files with 16 additions and 0 deletions

View File

@@ -5,5 +5,6 @@ from .bufjson import BufferedJSON
from .filehandler import FileHandler
from .randskip import randskip
from .sorter import Sorter
from .timestamp import make_bsread_timestamp

15
dap/utils/timestamp.py Normal file
View File

@@ -0,0 +1,15 @@
NANOS_PER_S = 10**9
NANOS_PER_MILLIS = 10**6
def make_bsread_timestamp(ts, pid):
"""
ts is assumed to be from time.time_ns() and NOT from time.time()
"""
secs, nanosecs = divmod(ts, NANOS_PER_S)
nanosecs = (nanosecs // NANOS_PER_MILLIS) * NANOS_PER_MILLIS + (pid % NANOS_PER_MILLIS)
return secs, nanosecs